akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back




int main() {
     cin.sync_with_stdio(0);cin.tie(0);
     cin.exceptions(cin.failbit);
    
     lli i,j,k,n,x,y,ans=0,u,v;
     cin>>n;
     //vvlli adj(n);
     rep(i,n){
         ans+=(1+i)*(n-i); 
     }
     rep(i,n-1){
          cin>>x>>y;
          x--;y--;
          u=min(x,y),v=max(x,y);
          ans-=(u+1)*(n-v);
     }
     // vlli s(n),a(n),b(n),d(n,n*2);
     // rep(i,n)s[i]=adj[i].size();
     // a[n-1]=1;
     // repD(i,n-2,0){
     //      a[i]=a[i+1]+s[i+1]-1;
     //      x=i+1;
     //      for (j=0;j<adj[x].size();j++){
     //           y=adj[x][j];
     //           s[y]--;
     //           if (y>x)d[x]=min(y,d[x]);
     //      }
     // }
     // x=0;
     // for (j=0;j<adj[x].size();j++){
     //    y=adj[x][j];
     //      s[y]--;
     //      if (y>x)d[x]=min(y,d[x]); 
     // }
     // b[n-1]=a[n-1];
     // repD(i,n-2,0){
     //      b[i]=b[i+1]+a[i];
     // }
     // dbgstl(a);dbgstl(d);
     // rep(i,n){
     //      ans+=b[i];
     //      if (d[i]!=2*n){
     //           x=d[i]-i-1;
     //           ans-= ((x+1)*x)/2;
     //      }
     //    // cout<<ans<<endl;
     // }
      cout<<ans<<endl;
   
   
   
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int x, n;
  cin >> x >> n;
  vector<bool> p(105, false);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    p[x] = true;
  }
  for (int i = 0; i <= 100; i++) {
    if (x - i >= 0) {
      if (p[x - i] == false) {
        cout << x - i << endl;
        return 0;
      }
    } else {
      cout << x - i << endl;
      return 0;
    }
    if (p[x + i] == false) {
      cout << x + i << endl;
      return 0;
    }
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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

int main(){
	int n,k;cin>>n>>k;
	string s;cin>>s;
	char a;
	a=tolower(s[k-1]);
	s[k-1]=a;
	cout<<s<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A >= 9 || B >= 9) 
    cout << ":(" << endl;
  else 
    cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200009
using namespace std;
typedef long long ll;
int main()
{
//    freopen("in.txt", "r", stdin);

    int n;
    cin>>n;
    set<string>s;
    while(n--)
    {
        string a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size();

    return 0;
}


Measured memory_bytes: 19228
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	string p[4]={"dream","dreamer","erase","eraser"};
	for(int i=0;i<4;i++){
		reverse(p[i].begin(),p[i].end());
	}
	for(int i=0;i<s.size();){
		bool f=false;
		for(int j=0;j<4;j++){
			if(s.compare(i,p[j].size(),p[j])==0){
				i+=p[j].size();
				f=true;
				break;
			}
		}
		if(!f){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

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

int main(){
 int a;
 int n;
 int max=-1000000;
 int min=1000000;

 long long sum=0;
 cin>> n;

 for(int i=1;i<=n;i++){
   cin>>a;
   sum=sum+a;
 if(a<min){
   min=a;
 }if(a>max){
   max=a;
  }
 }
 cout << min << " " << max << " " << sum << endl;
 return 0;
}


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

int main(){
  int n;
  cin >>n;
  vector<int> h(n);
  rep(i,n) cin >>h[i];
  int ans = 1;
  int curMax = h[0];
  for(int i = 1; i < n; i++){
    if(h[i]>=curMax && h[i]>=h[i-1]) {
      ans++;
    }
    curMax = max(curMax, h[i]);
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


class UnionFind{
    public:
        UnionFind(int N) : parent(N), rank(N){
            for(int i = 0; i < N; i++){
                parent[i] = i;
                rank[i] = 1;
            }
        }

        int find(int n){
            if(parent[n] == n){
                return n;
            }
            return parent[n] = find(parent[n]);
        }

        void merge(int m, int n){
            int root_x = find(m);
            int root_y = find(n);
            if(root_x == root_y){
                return;
            }
            if(rank[root_x] < rank[root_y]){
                parent[root_x] = root_y;
            }else if(rank[root_x] > rank[root_y]){
                parent[root_y] = root_x;
            }else{
                parent[root_y] = root_x;
                rank[root_x]++;
            }
        }

        bool equivalent(int x, int y){
            return find(x) == find(y);
        }

    private:
        vector<int> parent;
        vector<int> rank;

};

signed main(){
    int N, K, L;
    int p, q, r, s;
    cin >> N >> K >> L;
    map<pint, int> mp;
    UnionFind road(N), rail(N);
    REP(i, K){
        cin >> p >> q;
        p--; q--;
        road.merge(p, q);
    }
    REP(i, L){
        cin >> r >> s;
        r--; s--;
        rail.merge(r, s);
    }
    map<pint, int> count;
    REP(i, N){
        count[pint(road.find(i), rail.find(i))]++;
    }
    REP(i, N){
        cout << count[pint(road.find(i), rail.find(i))] << ((i < N - 1) ? " " : ENDL);
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n, zeronum = 0;
    cin >> n;
    if(n % 2 == 0){
        vector<int> a(n / 2);
        rep(i, n){
            int temp;
            cin >> temp;
            if(temp % 2 == 0){
                print(0);
                return 0;
            }
            a[temp / 2]++;
        }
        rep(i, n / 2){
            if(a[i] != 2){
                print(0);
                return 0;
            }
        }
        int ans = 1;
        rep(i, n / 2){
            ans = (ans * 2) % 1000000007;
        }
        print(ans);
    } else{
        vector<int> a((n / 2) + 1);
        rep(i, n){
            int temp;
            cin >> temp;
            if(temp % 2 == 1){
                print(0);
                return 0;
            }
            a[temp / 2]++;
        }
        if(a[0] != 1){
            print(0);
            return 0;
        }
        for(int i = 1; i < (n / 2) + 1; i++){
            if(a[i] != 2){
                print(0);
                return 0;
            }
        }
        int ans = 1;
        rep(i, n / 2){
            ans = (ans * 2) % 1000000007;
        }
        print(ans);
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int x,y,xx,yy;
    cin>>x>>y>>xx>>yy;
    int xdiff=xx-x,ydiff=yy-y;
    
    rep(i,0,ydiff)cout<<"U";
    rep(i,0,xdiff)cout<<"R";
    rep(i,0,ydiff)cout<<"D";
    rep(i,0,xdiff+1)cout<<"L";
    
    rep(i,0,ydiff+1)cout<<"U";
    rep(i,0,xdiff+1)cout<<"R";
    cout<<"DR";
    rep(i,0,ydiff+1)cout<<"D";
    rep(i,0,xdiff+1)cout<<"L";
    cout<<"U"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b; cin>>a>>b;
    if(a*b%2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3604
#define SUBMIT

// https://beta.atcoder.jp/contests/abc105

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    int N;
#ifdef SUBMIT
    cin >> N;
#else
//    N = 123456789;
//    N = -200;
#endif
    string ans;

    if (N == 0) {
        cout << "0" << endl;
        exit(0);
    }

    // odd number
    if (abs(N) % 2 != 0) {
        N -= 1;
        ans += "1";
    } else {
        ans += "0";
    }

    // digit
    int d = 1;
    while (N != 0)
    {
        int temp = N - static_cast<int>(pow(-2, d));
        if (abs(temp) % static_cast<int>(pow(2, d + 1)) == 0) {
            N = temp;
            ans += "1";
        } else {
            ans += "0";
        }

        d++;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());

            if (n % 10 == 3)
            {
                WriteLine($"bon");
            }
            else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
            {
                WriteLine($"pon");
            }
            else
            {

                WriteLine($"hon");
            }
        }
    }
}


Measured memory_bytes: 17612
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	int nn = a[n - 1];
	int mdiff = 2 * nn;
	int kk;
	for (int i = 0; i < n; i++) {
		int diff = abs(2 * a[i] - nn);
		if (diff < mdiff) {
			mdiff = diff;
			kk = a[i];
		}
	}
	cout << nn << " " << kk << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3908
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
int main()
{
	int a;
	cin >> a;
	int num = 1;
	while (num <= a / 2) {
		num *= 2;
	}
	cout << num << endl;
	return 0;
}

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

int main()
{
	unsigned int d[100], n,ret;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int i = n; i < 100; i++) {
		d[i] = 0;
	}
	sort(d, d+100,greater<>());
	ret = n;
	for (int i = 1; i < n; i++) {
		if (d[i] == d[i - 1]) {
			ret--;
		}
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
import time


_, = map(int,readline().split())
D = 365
*c, = map(int,readline().split())
s = tuple(tuple(map(int,readline().split())) for _ in range(D))

def output(ans):
    for i in ans: print(i+1)

def score(ans,s,c): # ans: 0-indexed としたときのスコアの計算
    last = [-1]*26
    score = 0
    for i, ai in enumerate(ans):
        score += s[i][ai]
        last[ai] = i
        for ci,li in zip(c,last):
            score -= ci*(i-li)
        #print(score) # i日目のスコア
    return score


#ans = [max(range(26),key=lambda x: si[x]) for si in s]
#ans = (list(range(26))*20)[:365]

def first_solution(s,c):
    minus = c[:]
    ans = [0]*365
    for i, si in enumerate(s):
        ans[i] = idx = max(range(26), key=lambda x:si[x]+minus[x])
        for i in range(26):
            minus[i] += c[i]
        minus[idx] = 0
    return ans        


"""
solution = 初期解(ランダム生成や、貪欲法など他の手法で求めたものを利用)
while 時間のある限り:
    solution を(ランダムに)少し変形
    if 変形前より解が悪化:
        solution を変形前の状態に戻す
"""


from bisect import bisect_left, bisect_right
"""
i 日目と i+1 日目を入れ替え
"""
def swap(i,ans,days,c,s):
    j = i+1
    ai = ans[i]
    aj = ans[j]
    di = days[ai]
    dj = days[aj]
    idx_i = bisect_left(di,-i)
    idx_j = bisect_left(dj,-j)
    
    #print(di,i,idx_i,ai)
    #print(dj,j,idx_j,aj)
    #assert di[idx_i] == -i and dj[idx_j] == -j 
    
    i_prev = -di[idx_i - 1]
    i_next = -di[idx_i + 1] if di[-1] != -i else -1

    j_prev = -dj[idx_j - 1]
    j_next = -dj[idx_j + 1] if dj[-1] != -j else -1

    delta_i = -c[ai]*(2*i-i_prev-i_next) + s[j][ai] - s[i][ai]
    delta_j = -c[aj]*(j_prev+j_next-2*i) - s[j][aj] + s[i][aj]
    #delta = delta_i + delta_j

    return delta_i + delta_j,idx_i,idx_j


def main(ans,s,c):
    from random import randrange,random
    from math import exp
    best = ans[:]
    start = time.time()
    days = [[-365] for _ in range(26)]
    for i in range(364,-1,-1):
        days[ans[i]].append(-i)

    while time.time() - start < 1.79:
        T = 200000*(max(2.0 - (time.time() - start),0.1))
        i = randrange(364)
        if ans[i] != ans[i+1]:
            delta,idx_i,idx_j = swap(i,ans,days,c,s)
            if delta > 0 or exp(-delta/T) >= random():
                days[ans[i]][idx_i] -= 1
                days[ans[i+1]][idx_j] += 1
                ans[i],ans[i+1] = ans[i+1],ans[i]
                if score(ans,s,c) > score(best,s,c):
                    best = ans[:]

        idx = randrange(26)
        a0 = ans[0]
        if a0 != idx:
            delta = s[0][idx] - s[0][a0] + c[a0]*(days[a0][-2]) - c[idx]*(days[idx][-1]+1)
            
            if delta > 0 or exp(-delta/T) >= random():
                ans[0] = idx
                days[idx].append(0)
                days[a0].pop()
                
                if score(ans,s,c) > score(best,s,c):
                    best = ans[:]
        
                

    return best

#print(score(ans,s,c))
output(main(first_solution(s,c),s,c))







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

int gcd(int a, int b) {
  if (b > a) {
    swap(a, b);
  }

  int r = a % b;
  while (r > 0) {
    a = b;
    b = r;
    r = b % r;
  }

  return b;
}

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

  int n = gcd(N, 2);
  cout << (N * 2) / n << endl;
}

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

using namespace std;
typedef long long ll;

int n;
int a[22][22];
int md = 1e9+7;
int dp[1<<22];
void addMd(int &x, int y)
{
    x += y;
    if (x >= md)
        x -= md;
}
int f(int msk)
{
    int cur = __builtin_popcount(msk);
    if (cur == n) return 1;
    int &ret = dp[msk];
    if (~ret) return ret;
    ret = 0;
    for (int i = 0; i < n; ++i)
        if (!((1<<i) & msk) && a[cur][i])
        {
            addMd(ret, f(msk | (1<<i)));
        }
    return ret;
}
int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        for (int j =0 ; j < n ; ++j)
            scanf("%d", &a[i][j]);
    printf("%d\n", f(0));

    return 0;
}


Measured memory_bytes: 16640
n = int(input())
count = 0
ans = 0
for i in range(1, n+1):
    if i%2 != 0:
        for j in range(1, n+1):
            if i%j == 0:
                count += 1
        if count == 8:
            ans += 1
        count = 0

print(ans)

Measured memory_bytes: 38768
#include<stdio.h>

void put_rstring(const char str[])
{
  unsigned length = 0;
  while(str[length])
  length++;
  for(; length>0; length--)
  putchar (str[length-1]);
}
  

int main()
{
 char str[21];
 scanf("%s",str);

 put_rstring(str);
 putchar('\n');
return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

struct Card{char suit,value;};

void bubble(struct Card A[],int N)
{
    for(int i=0;i<N;i++)
    {
        for(int j=N-1;j>=i+1;j--)
        {
            if(A[j].value<A[j-1].value)
            {
                Card t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
            }
        }
    }
}

void selection(struct Card A[],int N)
{
    for(int i = 0;i<N;i++)
    {int minj=i;
        for(int j=i;j<N;j++)
        {
            if(A[j].value<A[minj].value)minj=j;
        }
        Card t=A[i];A[i]=A[minj];A[minj]=t;
    }
}
void print(struct Card A[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(i>0) cout<<" ";
    cout<<A[i].suit<<A[i].value;

    }
    cout<<endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main()
{
    Card C1[100],C2[100];
    int N;
    char ch;

    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>C1[i].suit>>C1[i].value;
    }

    for(int i=0;i<N;i++) C2[i]=C1[i];

    bubble(C1,N);
    selection(C2,N);

    print(C1,N);
    cout<<"Stable"<<endl;
    print(C2,N);
    if(isStable(C1,C2,N))
    {
        cout<<"Stable"<<endl;
    }else{
    cout<<"Not stable"<<endl;
    }
    return 0;
}

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

int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }

int main() {
    int x;
    cin >> x;
    cout << ((x == 7 || x == 5 || x == 3) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    string S, T;
    cin >> S >> T;
    REP(j, 2)
    {
        map<char, char> m;
        REP(i, S.size())
        {
            if (m.count(T[i]) == 0)
            {
                m[T[i]] = S[i];
            }
            else
            {
                if (m[T[i]] != S[i])
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        swap(S, T);
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int T,a,b;ll ans;
db cal(ll x) {return (-(ll)b*x-1)*1./(a+x);}
int main()
{
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	for(scanf("%d",&T);T--;)
	{
		scanf("%d%d",&a,&b),ans=0;
		if(a<b) swap(a,b);
		if(a==1&&b==1) {puts("0");continue;}
		if(b>=20000000)
		{
			ll dd=sqrt(1ll*a*b),ans=dd*2-1;
			if(dd*dd==1ll*a*b)
			{
				if(a==b)ans--;
				else ans-=2;
			}
			else if(dd*(dd+1)>=1ll*a*b)ans--;
			cout<<ans<<endl;
			continue;
		}
		/*
		for(ll x=-a+1,y,tmp;;x++)
		{
			tmp=floor(((ll)-b*x-1)*1./(a+x));
			dbg1(x),dbg2(tmp);
			if(tmp==-b) break;
			if(tmp)
			{
				if(tmp^last) ans++,last=tmp;
				else
				{
					ans+=tmp+b-1;
					if(tmp>0) ans--;
					break;
				}
			}
		}
		dbg2(ans);*/
		ll l=-a+1,r=1e10,mid;
		for(;l<r;)
		{
			mid=l+r>>1;
//			dbg2(mid);
//			dbg1(cal(mid+1)),dbg2(cal(mid));
			cal(mid)-cal(mid+1)<1?r=mid:l=mid+1;
		}
//		dbg2(l);
		ll tmp1=floor((-(ll)b*l-1)*1./(a+l));
		ans=l+a+tmp1+b-1;
		if(l==-a+1)
		{
			if(tmp1>=0) ans--;
			cout<<ans<<"\n";
			continue;
		}
		ll tmp2=floor((-(ll)b*(l-1)-1)*1./(a+l-1));
//		dbg1(l-1),dbg1(cal(l-1)),dbg2(tmp2);
//		dbg1(l),dbg1(cal(l)),dbg2(tmp1);
//		dbg1(tmp1),dbg2(tmp2);
		if(tmp1>=0||tmp2<=0) ans--;
//		printf("%lld\n",ans);
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappushpop

def abc062_d():
    n = int(input())
    A = list(map(int, input().split()))

    front = A[:n]
    fsum = [0] * (3*n)
    fsum[n-1] = sum(front)
    heapify(front)
    for i in range(n, 2*n):
        fmin = heappushpop(front, A[i])
        fsum[i] = fsum[i-1] + A[i] - fmin

    back = [-1*a for a in A[2*n:]]
    bsum = [0] * (3*n)
    bsum[2*n] = -1 * sum(back)
    heapify(back)
    for i in range(2*n-1, n-1, -1):
        bmax = -1 * heappushpop(back, -1*A[i])
        bsum[i] = bsum[i+1] + A[i] - bmax

    ans = -10**18
    for i in range(n-1, 2*n):
        ans = max(ans, fsum[i] - bsum[i+1])
    print(ans)

if __name__ == '__main__':
    abc062_d()

Measured memory_bytes: 43876
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[200][3],m[200][3];
int main(){
int n,i,j,k;
cin>>n;
for(i=0;i<n;i++){
	for(j=0;j<3;j++)cin>>p[i][j];
}
memset(m,-1,sizeof(m));
for(i=0;i<3;i++){
	for(j=0;j<n;j++){
		if(m[j][i]==-1){
			for(k=j+1;k<n;k++){
				if(p[j][i]==p[k][i]){
					m[k][i]=0;
					m[j][i]=0;
				}
			}
		}
	if(m[j][i]==0)p[j][i]=0;
	}
}
for(i=0;i<n;i++){
p[i][2]=p[i][0]+p[i][1]+p[i][2];
cout<<p[i][2]<<endl;
}
return 0;
}

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

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (b == c && c == a && a == b) {
        puts("Yes");
    } else {
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    ll n,x,t;
    cin >> n >> x >> t;
    ll cur = (n+x-1)/x;
    cur *= t;
    cout << cur << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<ctype.h>
#define PI 3.141592653589
#define N_MAX 1000
#define NUM 26
 
int main()
{
  char buf[N_MAX], W[N_MAX];
  int count = 0,len, j;
  scanf("%s",W);
  len = strlen(W);
  for(j = 0; j < len; j++)
    {
      W[j] = tolower(W[j]);
    }
  char end[] = "END_OF_TEXT";
  while(1)
    {
      scanf("%s",buf);
      if(strcmp(buf,end) == 0) break;
      len = strlen(buf);
      for(j = 0; j < len; j++)
    {
      buf[j] = tolower(buf[j]);
    }
      if(strcmp(buf,W) == 0) count++;
    }
  printf("%d\n",count);
  return 0; 
}

Measured memory_bytes: 552
"""Minimum spanning tree with Kruskal's algorithm"""
import sys


class UnionFind:
    def __init__(self, n):
        # total number of nodes.
        self.n = n
        # node id -> root node id
        self._root_table = list(range(n))
        # root node id -> group size
        self._size_table = [1] * n

    def find(self, x):
        """Returns x's root node id."""
        r = self._root_table[x]
        if r != x:
            # Update the cache on query.
            r = self._root_table[x] = self.find(r)
        return r

    def union(self, x, y):
        """Merges two groups."""
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # Ensure that x is the larger (or equal) group.
        if self._size_table[x] < self._size_table[y]:
            x, y = y, x

        self._size_table[x] += self._size_table[y]
        self._root_table[y] = x

    def size(self, x):
        return self._size_table[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self._root_table) if x == i]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())


input = sys.stdin.readline


def main():
    N = int(input())
    cities, xs, ys = [], [], []
    for i in range(N):
        x, y = map(int, input().split())
        cities.append((x, y))
        xs.append((x, i))
        ys.append((y, i))
    xs.sort()
    ys.sort()
    xd, yd = [], []
    for i in range(1, N):
        x1, c1 = xs[i - 1]
        x2, c2 = xs[i]
        if x2 - x1 <= abs(cities[c1][1] - cities[c2][1]):
            xd.append((x2 - x1, c1, c2))
        y1, c1 = ys[i - 1]
        y2, c2 = ys[i]
        if y2 - y1 < abs(cities[c1][0] - cities[c2][0]):
            xd.append((y2 - y1, c1, c2))
    xd.sort()

    uf = UnionFind(N)
    cost = 0
    merged_cnt = 0
    for d1, c1, c2 in xd:
        if not uf.same(c1, c2):
            uf.union(c1, c2)
            cost += d1
            merged_cnt += 1
            if merged_cnt == N - 1:
                break
    print(cost)


if __name__ == "__main__":
    main()


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

int main(){
    char s,ans;
    cin>>s;
    if (s=='A') ans='T';
    if (s=='G') ans='C';
    if (s=='C') ans='G';
    if (s=='T') ans='A';
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

double dist(int x, int y)
{
    double xx = x;
    double yy = y;
    return sqrt(xx * xx + yy * yy);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d, e;
    while (1)
    {
        cin >> d >> e;
        if (d == 0 && e == 0)
        {
            break;
        }
        double ans = INF;
        for (int x = 0; x <= d; x++)
        {
            int y = d - x;
            chmin(ans, abs(dist(x, y) - e));
        }
        cout << fixed;
        cout << setprecision(10) << ans << endl;
    }
}


Measured memory_bytes: 3224
#include<iostream>
#include<list>
#include<vector>
#include<string>

using namespace std;
int main(){
  	string S_A, S_B, S_C;
    cin >> S_A;
  	cin >> S_B;
    cin >> S_C;
  	
  	int sizeA = S_A.size();
  	int sizeB = S_B.size();
  	int sizeC = S_C.size();
    
    int indexA = 0;
    int indexB = 0;
    int indexC = 0;
    char next = S_A[0];
  	indexA++;	
    while( indexA <= sizeA && indexB <= sizeB && indexC <= sizeC){
      if (next == 'a'){
        if(indexA < sizeA){
        	next = S_A[indexA];
        }
        indexA++;
      }
      else if (next == 'b'){
        if(indexB < sizeB){
        	next = S_B[indexB];
        }
        indexB++;
      }
      else if (next == 'c'){
        if(indexC < sizeC){
        	next = S_C[indexC];
        }
        indexC++;
      }
    }
  
    cout << (char)(next - 0x20) << endl;
}


Measured memory_bytes: 256
import numpy as np
import math

A, B, H, M = map(int, input().split())

Lx = B * math.sin(M / 30 * math.pi)
Ly = B * math.cos(M / 30 * math.pi)
Sx = A * math.sin((H / 6 + M / 360) * math.pi)
Sy = A * math.cos((H / 6 + M / 360) * math.pi)

#print(Lx, Ly, Sx, Sy)

print(math.sqrt(pow(Sx - Lx, 2) + pow(Sy - Ly, 2)))


Measured memory_bytes: 27188
N=input()
K=int(input())

dp=[[[0 for _ in range(K+2)] for _ in range(2)] for _ in range(len(N)+1)]

dp[0][0][0]=1

for i in range(len(N)):
    for smaller in range(2):
        for j in range(K+1):
            for x in range(10 if smaller==1 else int(N[i])+1):
                dp[i+1][smaller or (x < int(N[i]))][j+1 if x!=0 else j]+=dp[i][smaller][j]
print(dp[len(N)][1][K]+dp[len(N)][0][K])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin >> s;
	string t = "CODEFESTIVAL2016";
	int ans = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != t[i]) ans++;
	}
	cout << ans << endl;
	return 0;                                              
}
	


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[input() for i in range(N)]
B=''.join([input() for i in range(M)])
f=0
for i in range(N-M+1):
    for j in range(N-M+1):
        if ''.join([A[l][j:j+M] for l in range(i,i+M)])==B:
            f=1
print(['No','Yes'][f])

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
/*
int solve(int x){
	int n=x-1;
	for(int k=0;k<=n-k;k++){
		
	}
}*/
/*
ll dp[62][2][62];

ll solve(ll x){
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	rep(i,61)rep(j,2)rep(k,i+1){
		int last=60-i;
		int bit=x>>last&1;
		int lim=(j?1:bit);
		for(int t=0;t<=lim;t++){
			(dp[i+1][j||t<lim][k+t]+=dp[i][j][k])%=MOD;
		}
	}
	ll ans=0;
	rep(i,2)rep(j,62){
		if(j==0)continue;
		if(dp[61][i][j]==0)continue;
		ll c=1LL<<(j-1);c%=MOD;
		(ans+=c*dp[61][i][j])%=MOD;
	}
	return ans;
}
*/

ll dp[62][2][2][2];

ll solve(ll L,ll R){
	memset(dp,0,sizeof(dp));
	dp[0][0][0][0]=1;
	rep(i,61)rep(j,2)rep(k,2)rep(t,2){
		if(dp[i][j][k][t]==0)continue;
		//~ cout<<i<<' '<<j<<' '<<k<<' '<<t<<endl;
		int last=60-i;
		int bit=R>>last&1;
		int lim=(k?1:bit);
		for(int l=0;l<=lim;l++){
			int bit2=L>>last&1;
			int lim2=(t?0:bit2);
			if(l==1&&j==0)lim2=1;
			for(int m=lim2;m<=l;m++){
				(dp[i+1][j||l][k||l<lim][t||bit2<m]+=dp[i][j][k][t])%=MOD;
			}
		}
	}
	ll ans=0;
	rep(j,2)rep(k,2)rep(t,2){
		(ans+=dp[61][j][k][t])%=MOD;
	}
	/*
	ll ans=0;
	rep(i,2)rep(j,62){
		if(j==0)continue;
		if(dp[61][i][j]==0)continue;
		ll c=1LL<<(j-1);c%=MOD;
		(ans+=c*dp[61][i][j])%=MOD;
	}*/
	return ans;
}
int main(){
	ll l,r;cin>>l>>r;
	cout<<solve(l,r)<<endl;
	//~ ll l,r;cin>>l>>r;
	//~ cout<<solve(r)-solve2(l-1)<<endl;
	//~ for(int i=1;i<=100;i++){
		//~ int cnt=0;
		//~ for(int j=i;j<=1000;j++){
			//~ if(j%i==(i^j)){
				//~ cout<<bitset<10>(i)<<' '<<bitset<10>(j)<<endl;
				//~ cout<<i<<' '<<j<<endl;
				//~ cnt++;
			//~ }
		//~ }
		//~ cout<<cnt<<",";
		//~ cout<<i<<' '<<cnt<<endl;
	//~ }
	
	//~ int sum=0;
	//~ for(int i=1;i<=100;i++){
		//~ int cnt=0;
		//~ for(int j=1;j<=i;j++){
			//~ if(i%j==(i^j)){
				//~ cout<<bitset<10>(i)<<' '<<bitset<10>(j)<<endl;
				//~ cnt++;
			//~ }
		//~ }
		//~ sum+=cnt;
		//~ cout<<sum<<',';
		//~ cout<<cnt<<',';
		//~ cout<<biset<10>(i)<<' '<<cnt<<endl;
		//~ cout<<i<<' '<<(1<<(__builtin_popcount(i)-1))<<' '<<cnt<<endl;
	//~ }
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
const int nmax=200005;
int a[nmax],ans[nmax];
vector<int> dp(nmax,inf);
vector<vector<int>> g(nmax);
void dfs(int s,int p=-1){
    int b=lower_bound(dp.begin(),dp.end(),a[s])-dp.begin();
    int bef=dp[b];
    dp[b]=a[s];
    ans[s]=b;
    if(p!=-1){
        chmax(ans[s],ans[p]);
    }
    for(int x:g[s]){
        if(x==p){
            continue;
        }
        dfs(x,s);
    }
    dp[b]=bef;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        int u,v;cin >> u >> v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0);
    for(int i=0;i<n;i++){
        cout << ans[i]+1 << endl;
    }
}

Measured memory_bytes: 27920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char N;
  cin >> N;
  vector<char> a={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  if (!binary_search(a.begin(), a.end(),N)){
    cout << 'a' <<endl;
    }
  else{
    cout << 'A' <<endl;
  }
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define read(x) scanf("%d",&x)
typedef long long ll;
typedef double dl;
using namespace std;

const int N=2e5+7;
const int M=1e9+7;
const int INF=0x3f3f3f3f;

ll n,m;

void solve(){
	cin>>n;
	int cnt=0;
	if (n!=1) cnt++;
	if (n>2) cnt++;
	for(ll i=2;i*i<=n;i++){
		if (n%i!=0){
			if (n%i==1){
				cnt++;
//				cout<<i<<endl;
				if (n % ((n-1)/i) != 0&&(n-1)/i!=i){
					cnt++; 
					//cout<<(n-1)/i<<endl;
				}
			}
		}
		else{
			ll tmp=n;
			while (tmp!=0&&tmp%i==0) tmp/=i;
			if (tmp%i==1) cnt++;//cout<<i<<endl;
			if (i%(n/i)==1&&n/i!=i) cnt++;//cout<<n/i<<endl;
		}
	}
	cout<<cnt;
}

int main(){
//	ios::sync_with_stdio(0);
//  cin.tie(0),cout.tie(0);
//	int T;read(T);
//	for(int i=1;i<=T;i++)
		solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  sort(all(a));

  cout<<a[n/2]-a[n/2-1]<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
  static char[] o, e;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    o = sc.next().toCharArray();
    e = sc.next().toCharArray();

    StringBuilder sb = new StringBuilder();
    int i = 0, j = 0;
    for(int k = 0; k < o.length + e.length; k++){
      if((k + 1) % 2 == 0){
        sb.append(e[i++]);
      }
      else{
        sb.append(o[j++]);
      }
    }

    System.out.println(sb);
  }
}


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

int main(){
	int a, b = 0;
	cin >> a;
	for(int i = 1; i < 10; i++){
		if(a % i == 0 && a / i < 10){
          cout << "Yes" << endl;
          b++;
          break;
        }
	}
	if(b == 0)cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{ 
  int n,i;
  scanf("%d",&n);
  double x[n],s=0,t=0,sum=0;
  char u[n][3];
  for(i=0;i<n;i++)
    scanf("%lf %s",&x[i],&u[i][0]);
  for(i=0;i<n;i++)
    if(u[i][0]=='J') s+=x[i];
      else t+=x[i];
  sum=s+t*380000.0;
  printf("%lf",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long A;
    scanf("%lld",&A);
    long double B;
    scanf("%Lf",&B);
    ll b=B*1000;
    // debg(b);
    unsigned long long ret=A*b;
    // debg(ret);
    // debg(ret/1000);
    cout << ret/1000 << endl;
    return 0;
}


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

int main() {
	long long n,k,ans=1,i;
	cin >> n >> k;
	for(i=0; i<n; i++){
		if(ans<k){
			ans*=2;
		}else{
			ans+=k;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int n;
char dt[1000][1000];
int l[1000][1000],u[1000][1000];
int sq[1000][1000];
		

int min(int x,int y){
	if(x<y)return x;
	else return y;
}

int max(int x,int y){
	if(x>y)return x;
	else return y;
}

int main(){
	while(cin>>n,n){
		rep(i,n){
			rep(j,n){
				cin>>dt[i][j];
				if(dt[i][j]=='.'){
					if(j>0)l[i][j]=l[i][j-1]+1;
					else l[i][j]=1;
					if(i>0)u[i][j]=u[i-1][j]+1;
					else u[i][j]=1;
					if(i==0 || j==0)sq[i][j]=1; 
				}else{
					l[i][j]=u[i][j]=sq[i][j]=0;
				}
			}
		}
		loop(i,1,n){
			loop(j,1,n){
				sq[i][j]=min(min(l[i][j],u[i][j]),sq[i-1][j-1]+1);
			}
		}
		int ans=0;
		rep(i,n)rep(j,n)ans=max(ans,sq[i][j]);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 13856
N, Ma, Mb = map(int, input().split())
abc = [list(map(int, input().split())) for i in range(N)]
INF = 10**5
n = 10*N + 1
dp = [[[INF]*n for i in range(n)] for j in range(N+1)]
dp[0][0][0] = 0

for i, (a, b, c) in enumerate(abc, 1):
  for j in range(n):
    for k in range(n):
      dp[i][j][k] = dp[i-1][j][k]
      if a <= j and b <= k:
        dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a][k-b]+c)

ans = INF
dp[-1][0][0] = INF
for j in range(n):
  for k in range(n):
    if j * Mb == k*Ma:
      ans = min(ans, dp[-1][j][k])

if ans < INF:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 98012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=1e6+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,a[N];
char s[N];

bool C(int n,int m) {
	return (n&m)==m;
}

int work(bool f) {
	bool tmp=0;
	for(int i=1;i<=n;i++)
		if(a[i]==1) tmp^=C(n-1,i-1);
	if(tmp) return 1+int(f);
	bool fl=0;
	for(int i=1;i<=n;i++)
		if(a[i]==1) fl=1;
	if(fl||f) return 0;
	for(int i=1;i<=n;i++) a[i]/=2;
	return work(1);
}

int main() {
	cin>>n;scanf("%s",s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0'-1;
	cout<<work(0);
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int h, w, n, tmp;
    sc(h) sc(w) sc(n)
    int a[n];
    for (int i = 0; i < n; i++) sc(a[i])
    int ans[h][w];
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            ans[i][j] = -1;
        }
    }
    int row = 0, col = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < a[i]; j++){
            if (row % 2 == 0 && col == w - 1){
                ans[row][col] = i + 1;
                row += 1;
            }else if (row % 2 == 1 && col == 0){
                ans[row][col] = i + 1;
                row += 1;
            }else {
                ans[row][col] = i + 1;
                if (row % 2 == 0) col += 1;
                else col -= 1;
            }
        }
    }
    for (int i = 0; i < h; i++){
        cout << ans[i][0];
        for (int j = 1; j < w; j++){
            cout << " " << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
    int n; cin >> n;
    vector<pair<pair<string, int>, int>> P(n);

    for (int i=0;i<n;i++) {
        string s;
        int p;
        cin >> s >> p;

        P.at(i).first = make_pair(s, -p);
        P.at(i).second = i;
    }

    sort(P.begin(), P.end());

    for (int i=0;i<n;i++){
        cout << P.at(i).second + 1 << endl;
    }

    return 0;
}

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

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

    // vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        // cin >> A[i];
        int n;
        cin >> n;
        sum += n;
    }

    if (sum % 2 == 0)
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 384