akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        int answer = 1;
        while (true)
        {
            if (answer * 2 > n)
            {
                break;
            }
            answer *= 2;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
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; }

int main() {
	int N;cin >> N;
	int a[N][3];
	REP(i,N){
		REP(k,3){
			cin >> a[i][k];
		}
	}
	
	ll DP[N+1][3] = {};
	REPS(i, N) {
		REP(k, 3){
			chmax(DP[i][k], DP[i-1][(k+1)%3] + a[i-1][k]);
			chmax(DP[i][k], DP[i-1][(k+2)%3] + a[i-1][k]);
		}
	}
	cout << max(max(DP[N][0],DP[N][1]),DP[N][2]);
}

Measured memory_bytes: 3712
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}


void Main()
{
    int n;cin>>n;
    string s; cin>>s;

    vector<set<int>> m(26);
    REP(i,n){
        m[s[i] - 'a'].insert(i);
    }

    int q;cin>>q;

    REP(k,q){
        int type;cin>>type;

        if(type == 1){
            int i;
            char c;
            cin>>i>>c;
            i--;
            char now = s[i];
            s[i] = c;
            m[now-'a'].erase(i);
            m[c-'a'].insert(i);
            
        }

        if(type == 2){
            int result = 0;
            int r,l;cin>>r>>l;
            r--;l--;
            for(const auto& a : m){
                //for (set<int>::iterator it = a.begin(); it != a.end(); it++) {
                //    cout << *it ;
                //}
                //cout << endl;
    
                if(a.lower_bound(r) != a.upper_bound(l)){
                    result++;
                }
            }
            cout << result <<endl;

        }

    }
    
	return;
}

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

Measured memory_bytes: 24348
#include<stdio.h>
int main(void)
{
	
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
		return 0;
}

Measured memory_bytes: 580
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    int N;
    string S1, S2;
    enum Block{
        Vertical,
        Horizontal
    }
    void Solve() {
        //input
        N = io.Int;
        S1 = io.String;
        S2 = io.String;
        //cal
        var mod =1000000007;
        var blockStatus = new Queue<Block>();
        var reS1 = S1.Distinct().ToArray();
        var reS2 = S2.Distinct().ToArray();
        Func<int, bool> isVertical = (index) 
            => reS1[index] == reS2[index];
        for (int i = 0; i < reS1.Count(); ++i) {
            if (isVertical(i)) {
                blockStatus.Enqueue(Block.Vertical);
            } else {
                blockStatus.Enqueue(Block.Horizontal);
            }
        }
        var preStatus = blockStatus.Dequeue();
        var ans = preStatus == Block.Vertical ? 3L : 6L;

        while (blockStatus.Count() > 0) {
            var curStatus = blockStatus.Dequeue();
            if (preStatus == Block.Horizontal &&
                curStatus == Block.Vertical) {
                //ans = ans * 1
            } else if (preStatus == Block.Horizontal &&
                       curStatus == Block.Horizontal) {
                ans = (ans * 3) % mod;
            } else {
                ans = (ans * 2) % mod;
            }
            preStatus = curStatus;
        }
        //ret
        WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 13408
def solve():
    can_positive = False
    if len(P) > 0:
        if k < n:
            can_positive = True
        else:
            can_positive = len(M) % 2 == 0
    else:
        can_positive = k % 2 == 0
    if not can_positive:
        return sorted(P + M, key=lambda x: abs(x))[:k]
    P.sort()
    M.sort(reverse=True)
    a = [P.pop()] if k % 2 else [1]
    while len(P) >= 2:
        a.append(P.pop() * P.pop())
    while len(M) >= 2:
        a.append(M.pop() * M.pop())
    return a[:1] + sorted(a[1:], reverse=True)[:(k - k%2) // 2]

n, k = map(int, input().split())
P, M = [], []
for a in map(int, input().split()):
    if a < 0:
        M.append(a)
    else:
        P.append(a)
ans, mod = 1, 10 ** 9 + 7
for a in solve():
    ans *= a
    ans %= mod
print(ans)

Measured memory_bytes: 32564
#include <stdio.h>
  
int main(void){
  
int a, b, c, d;
  
while(scanf("%d %d", &a, &b)!=EOF){
  
c=a+b;
d=0;
  
while(c>0){
  
c=c/10;
d++;
}
  
printf("%d\n", d);
  
}
  
return 0;
}

Measured memory_bytes: 600
// inputに入力データ全体が入る
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	gyou = input[0];
	var count=0;
	for(i=1;i<=gyou;i++){
		var flag =0;
		for(j=i+1;j<=gyou;j++){
			if(input[i]==input[j]){
				flag = 1;
			}
		}
		if(flag==0){
			count++
		}
		
		
	}



	//出力
	console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> L(N + 1);
  
  L.at(0) = 2;
  L.at(1) = 1;
  
  for (int i = 2; i < N + 1; i++)
    L.at(i) = L.at(i - 2) + L.at(i - 1);
  
  printf("%ld", L.at(N));
}


Measured memory_bytes: 256
// ALDS1_6_C.cpp
// Sort II - Quick Sort

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Card
{
//	Card(char ch, int num) : ch(ch), num(num) { }
	char ch;
	int num;
};

bool operator<(const Card & c1, const Card &c2) {
	return c1.num < c2.num;
}

void bubblesort(vector<Card>& cards, int l, int r)
{
	for (int i = l; i <= r; i++) {
		for (int j = r; j > i; j--) {
			if (cards[j].num < cards[j-1].num)
				swap(cards[j], cards[j-1]);
		}
	}
}

int Partition(vector<Card>& cards, int l, int r)
{
	int tmp = cards[r].num;
	int i = l - 1;
	for (int j = l; j < r; j++) {
		if (cards[j].num <= tmp) {
			i++;
			swap(cards[i], cards[j]);
		}
	}
	swap(cards[++i], cards[r]);
	return i;
}

void qsort(vector<Card>& cards, int l, int r)
{
	if (l >= r) return;
	int pivot = Partition(cards, l, r);
	qsort(cards, l, pivot - 1);
	qsort(cards, pivot + 1, r);
}

void show(vector<Card>& cards)
{
	for (int i = 0; i < cards.size(); i++) {
		cout << cards[i].ch << " " << cards[i].num << endl;
	}
}

bool isSame(vector<Card>& c1, vector<Card>& c2)
{
	if (c1.size() != c2.size()) return false;
	for (int i = 0; i < c1.size(); i++) {
		if (c1[i].ch != c2[i].ch || c1[i].num != c2[i].num)
			return false;
	}
	return true;
}



int main()
{
	int n;
	cin >> n;
	vector<Card> cards(n);
	for (int i = 0; i < n; i++) {
		cin >> cards[i].ch >> cards[i].num;
	}
	vector<Card> cards2(cards);
	qsort(cards, 0, n - 1);
	// bubblesort(cards2, 0, n - 1);
	stable_sort(cards2.begin(), cards2.end());
	if (isSame(cards, cards2))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	show(cards);
	return 0;
}

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

signed main() {
    int N, M; cin >> N >> M;
    vector<int> x(N), y(M);
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];
    const int MOD = 1e9 + 7;
    int hs = 0, ws = 0;
    REP(i, 1, N) hs = (hs + (x[i] - x[0])) % MOD;
    REP(i, 1, M) ws = (ws + (y[i] - y[0])) % MOD;
    int H = hs, W = ws;
    rep(i, N - 1) {
        H = (H + hs) % MOD;
        int sub = -(x[i + 1] - x[i]) * (N - 1 - i);
        sub = sub + (sub / MOD + 1) * MOD;
        (H += sub) %= MOD;
        (hs += sub) %= MOD;
    }
    rep(i, M - 1) {
        W = (W + ws) % MOD;
        int sub = -(y[i + 1] - y[i]) * (M - 1 - i);
        sub = sub + (sub / MOD + 1) * MOD;
        (W += sub) %= MOD;
        (ws += sub) %= MOD;
    }
    
    cout << (H * W) % MOD << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<30;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
//vector< vector<int> > v (max1, vector<in t>(max2) );

int a[100000] = {};


int main() {
	int n,k;
	cin >> n>>k;
	rep(i, n) {
		//cin >> a[i];
	
	}
	if (n - k <= 0) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 1;
	n -= k;
	ans += n / (k - 1);
	if (n % (k - 1))ans++;


	
	cout << ans << endl;
	int nn;
	cin >> nn;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                cnt++;
            }
        } else {
            if (s[i] == 'R') {
                cnt++;
            }
        }
    }
    if (cnt) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int  P(int* A,int p,int r);

int main()
{
    int* a;
	int N,num;
    cin>>N;
	a=new int[N];
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	num=P(a,0,N-1);
    for(int i=0;i<N;i++){
        if(i){
            cout<<' ';
        }
        if(i==num){
            cout<<'['<<a[i]<<']';
        }else{
            cout<<a[i];
        }
    }
    cout<<endl;
}
int  P(int* A,int p,int r)
{
	int x=A[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(A[j] <= x){
            i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s,t; cin >> s >> t;
    reverse(all(t));
    if(s==t)out("YES");
    else out("NO");
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,s,sum;
	cin>>n>>sum;
	s=n;
	int num[n];
	for(int i=0;i<n;i++)
		cin>>num[i],sum-=num[i];
	sort(num,num+n);
	s+=sum/num[0];
	cout<<s;
	return 0;
}

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

int main(){
    int m, d, count, i, j;

    cin >> m >> d;
    count = 0;
    for(i = 1; i <= m; i++){
        for(j = 1; j <= d; j++){
            int dezena = j/10;
            int unidade = j%10;
            if(dezena*unidade == i){
                if(dezena >= 2 && unidade >= 2){
                    count++;

                }
            }
        }
    }

    cout << count << endl;
}

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

int main() {
	int i, j, a[3];

	cin >> a[0] >> a[1] >> a[2];
	for (i = 0; i < 2; i++) {
		for (j = 0; j < 2-i; j++) {
			if (a[j] > a[j+1]) swap(a[j], a[j+1]);
		}
	}

	cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
	return 0;
}

Measured memory_bytes: 3092
# -*-coding: utf-8 -*-
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

flag = True

x = sorted(x)
y = sorted(y)

if Y - X < 2:
    flag = False

if y[0] <= x[-1] or (y[0] <= X or x[-1] >= Y):
    flag = False


if flag:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

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

		int left = -1;
		int right = -1;	

		for (int i = 2; i < 4; i++) {
			for (int j = 0; j <= line.length() - i; j++) {
				String target = line.substring(j, j+i);
				if (target.substring(0, 1).equals(target.substring(i-1, i))) {
					left = j + 1;
					right = j+i;
					break;
				}
			}
			if (left > -1 && right > -1) {
				break;
			}
		}

		System.out.println(left + " " + right);

		scanner.close();
	}

}


Measured memory_bytes: 46332
S_prime = input()
T = input()
lenS = len(S_prime)
lenT = len(T)
existflag = 0
kouho = []
index = 0
for i in range(lenS-lenT+1):
    index = i
    # print(index)
    for j in range(lenT):
        flag = 1
        if S_prime[i + j] != "?" and S_prime[i + j] != T[j]:
            flag = 0
            break
    if flag == 1:
        kouho.append(
            (S_prime[:index] + T + S_prime[index+lenT:]).replace("?", "a"))


# print(index)
if len(kouho) == 0:
    print("UNRESTORABLE")
else:
    print(min(kouho))


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


  
int main(){
    int n;
    cin>>n;
    double dn=(double)n;
    vector<double> p(n);
    rep(i,n)cin>>p[i];
    double dp[3000][3000];
    dp[0][0]=1;
    rep2(1,j,n+1)dp[0][j]=0;

    rep(i,n){
        rep2(0,j,i+2){
            if(j==0)dp[i+1][j]=dp[i][j]*(1-p[i]);
            else dp[i+1][j]=(dp[i][j]*(1.0-p[i])+dp[i][j-1]*p[i]);
            //cout<<"dp["<<i+1<<"]["<<j<<"]= "<<dp[i+1][j]<<endl;
        }
    }

    double sum=0;
    for(int i=n/2+1;i<=n;i++)sum+=dp[n][i];
    
    cout<<setprecision(15)<<sum<<endl;
    return 0;
}

Measured memory_bytes: 70400
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;vector<int> a(n);REP(i,n)cin>>a[i];
	int ct = 0;
	REP(i,n){
		RFOR(j,n,i+1){
			if(a[j] < a[j-1]){
				swap(a[j],a[j-1]);
				ct++;
			}
		}
	}
	REP(i,n){if(i)cout<<' ';
		cout << a[i];
	}
	cout << '\n' << ct << endl;
  return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[1];
int size=1;
int m=2;
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
/*
bool prime(ll n){if(n==1)return false;for(ll i=2;i*i<=n;i++)if(n%i==0){return false;}return true;}
void prime_fact(int n){for(int i=2;i*i<=n;i++){int count=0;if(n%i==0){while(n%i==0)n/=i,count++;cout<<i<<"^"<<count<<" ";}}if(n>1)cout<<n<<"^1";}
ll power(ll base ,ll pow){ll res=1;while(pow>0){if(pow&1)res*=base,pow-=1;else base*=base,pow/=2;}return res;}
void prime_fact_seieve(int n){for(int i=2;i<=size;i++){if(A[i]==0)for(ll j=i;j<=size;j+=i)if(A[i]==0)A[j]=i;}while(n>2){cout<<A[n]<<"*";n/=A[n];}}
template <class X> X gcd(X a , X b) { return b==0?a: gcd( b, a%b); }
template <class X> X lcm(X a , X b) { return a/gcd(a,b) * b ; }
ll Ab[N][N],I[N][N];  // identity matrix and a matrix to store result
void multiply(ll I[][N],ll A[][N],int dim)
{   int res[dim+1][dim+1];
    for(int i=0;i<dim;i++)
    {  for(int j=0;j<dim;j++)
        {
           res[i][j]=0;
           for(int k=0;k<dim;k++)
           {  res[i][j]+=((I[i][k]%mod)*(A[k][j])%mod)%mod;}}}

        for(int i=0;i<dim;i++)
            for(int j=0;j<dim;j++)
                I[i][j]=res[i][j];}
void powerMat(ll A[][N],int dim,int n)
{   for(int i=0;i<dim;i++)
    for(int j=0;j<dim;j++)
    {if(i==j) I[i][j]=1;
     else     I[i][j]=0;}
     while(n>0)
     {
         if(n%2)
         multiply(I,A,dim),n--;
         else
         multiply(A,A,dim),n/=2;
     }
     for(int i=0;i<dim;i++)
         for(int j=0;j<dim;j++)
             A[i][j]=I[i][j];
}
void printMat(ll A[][N],int dim)
{
    for(int i=0;i<dim;i++)
    {for(int j=0;j<dim;j++)
        {
            cout<<A[i][j]<<" ";
        }cout<<"\n";}
}
// REMEMBER PREFIX SUM SUFFIX SUM OR GCD VERY INTERESTING QUESTIONS
ll power(ll base ,ll pow,ll mo){ll res=1;while(pow>0){if(pow&1)res=(res%mo*base%mo)%mo,pow-=1;else base=(base%mo*base%mo)%mo,pow/=2;}return res;}*/
int main()
{ int n,k;ll sum=0;
  cin>>n>>k;
  int arr[n];
  f(i,n)cin>>arr[i];
  sort(arr,arr+n);
  f(i,k)sum+=arr[i];cout<<sum;

}


Measured memory_bytes: 3596
/**
 *  author: Behradm
 *  Created: 2020.06.27 17:30:09
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e7+1;
long long f[maxn];

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      f[j] += 1;
    }  
  } 

  long long res = 0;
  for (int i = 0; i < n; i++)
    res += (i + 1) * f[i + 1] * 1LL;

  cout << res << '\n';
  return 0;
}


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


int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n)
    cin >> a[i];
  ll c = 1, d = 1;
  while (d<<1 <= 1e12)
  {
    d <<= 1;
    c++;
  }
  vector<int> count(c, 0);
  rep(i, n)
    rep(j, c)
    {
      if (a[i] & 1)
        count[j]++;
      a[i] >>= 1;
    }
  vector<vector<ll>> dp(c + 1, vector<ll>(2));
  for (int i=c-1; i>=0; i--)
  {
    if (k & d)
      dp[i][1] = dp[i+1][1] + (n - count[i]) * d;
    else
      dp[i][1] = dp[i+1][1] + count[i] * d;
    if (dp[i+1][0] > 0)
      dp[i][0] = dp[i+1][0] + max(count[i], n - count[i]) * d;
    if (k & d)
      dp[i][0] = max(dp[i][0], dp[i+1][1] + count[i] * d);
    d >>= 1;
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
  return 0;
}

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

int c,sq[18];

int count(int n,int i){
	if(n==0)return 0;
	int j;
	for(j=i;j>=1;j--){
		if(n<sq[j])continue;
		if(n==sq[j]){
			++c;
			continue;
		}
		count(n-sq[j],j);
	}
	return 0;
}

int main(){

	int i,j,n;
	
	for(i=0;i<=17;i++){
		sq[i]=i*i;
	}
	
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		c=0;
		
		for(i=1;i<=17;i++){
			if(n<sq[i]){
				--i;
				break;
			}
		}
		count(n,i);
		printf("%d\n",c);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if(s=="AC") ac++;
    if(s=="WA") wa++;
    if(s=="TLE") tle++;
    if(s=="RE") re++;
  }
  
  cout << "AC x " << ac << endl << "WA x " << wa << endl << "TLE x " << tle << endl << "RE x " << re << endl;
}

Measured memory_bytes: 3628
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


/*======================================================================*/
void solve(){
    int c1 = 0, c2 = 0, n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0, j = n-1;
    int ans  = 0;
    while(i < j){
        while(i < n and s[i] == 'R')i++;
        while(j >= 0 and s[j] == 'W')j--;
        if(i < j)i++, j--, ans++;
    }
    cout << ans;
}
signed main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

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

void Main()
{
    int64_t X;
    cin >> X;
    int64_t count = 0;
    int64_t x = 100;
    while(true)
    {
        if(x >= X)
        {
            break;
        }
        ++count;
        x += x / 100;
    }

    cout << count << endl;
}

int main()
{
    Main();
}


Measured memory_bytes: 3620
a = list(map(int,input().split()))
ans = a[1]
c = a[0]%2+a[3]%2+a[4]%2
if c == 3:
  ans += a[0]+a[3]+a[4]
elif c == 2 and a[0]*a[3]*a[4] != 0:
  ans += a[0]+a[3]+a[4]-1
else:
  ans += a[0]//2*2+a[3]//2*2+a[4]//2*2
print(ans)

Measured memory_bytes: 38384
n, a = gets.chomp.split(" ").map{|x| x.to_i}

ans = n

for x in 1...32
  for k in 0..x
    l = x - k
    # puts "x = #{x}, k = #{k}"
    m = (n**(1.0/x)-1).ceil()
    if m**k * (m+1)**l >= n
      ans = [ans, m * k + (m+1) * l + a * (k + l - 1)].min()
    end
  end
end

puts ans



Measured memory_bytes: 1788
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



n,m,k = list(map(int, input().split()))

                             
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)





total = 1
for i in range(n):
    total *= m
    total %= p

powm1 = [1]
now = 1
for i in range(3*10**5):
    now *= m-1
    now %= p
    powm1.append(now)

ans = 0
for i in range(k+1):
    parts = n-i
    alloc = cmb(n-1,parts-1,p)
    col = m * powm1[parts-1] % p
    #print(i,alloc,col)
    ans += alloc * col % p
    ans %= p

print(ans)
















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

int main() {
  int N, T, A;
  cin >> N >> T >> A;

  double mni = 1e9;
  int cnt = 1, ans;

  for (int i = 0; i < N; i++) {
    int H;
    cin >> H;
    double tem = T - H * 0.006;
    if (abs(A - tem) < mni) mni = abs(A - tem), ans = cnt;
    cnt++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  
  check = zeros(Int,M)
  ans = 0
  
  for i in 1:N
    
    A = map(x -> parse(Int,x), split(readline()))
    
    for j in 1:M
      
      if in(j,A[2:end])
        check[j] += 1
      end
      
    end
    
  end
  
  for i in 1:M
    
    if check[i] == N
      ans += 1
    end
    
  end
  
  println(ans)
  
end
    
main()

Measured memory_bytes: 112780
n=int(input())
G=[[j for j in range(n)] for i in range(n)]
for i in range(n):
    g_in=list(map(int,input().split()))
    u=g_in[0]
    k=g_in[1]
    v=g_in[2:]
    for j in v:
        G[u-1][j-1]=1

visited=[0 for i in range(n)]
finished=[0 for i in range(n)]
L=[]
out=[[i+1,0,0] for i in range(n)]
step=0

def dfs(cn):
    flg=0
    if visited[cn]==0:
        flg=1
        L.append(cn)
    visited[cn]=1
    for i in range(n):
        if cn!=i and G[cn][i]==1 and visited[i]==0:
            dfs(i)
    if flg==1:
        L.append(cn)

i=0
while visited.count(1)<n:
    dfs(i)
    i+=1
copied=[0 for i in range(len(L))]

for i in range(len(L)):
    if copied[L[i]]==0:
        copied[L[i]]=1
        out[L[i]][1]=i+1
    elif copied[L[i]]==1:
        copied[L[i]]=2
        out[L[i]][2]=i+1

out=[' '.join(map(str,i)) for i in out]
#print(' '.join(map(str,[i+1 for i in L])))
print('\n'.join(map(str,out)))


Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
const int MOD=1e9+7;

int N;

map<int,int> divs;

int main(){
	cin>>N;
	if (N==1){
		printf("1\n");
		return 0;
	}
	FOR(i,2,N+1){
		int n=i,d=2;
		while(n!=1){
			if (n%d==0){
				n/=d;
				divs[d]++;
			}else{
				d++;
			}
		}
	}
	ll ans=1;
	for(auto d:divs){
		ans*=(d.second+1);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
a = [max(1, N//R), max(1, N//G)]
ans = 0
for i in range(0, a[0]+1):
    for j in range(0, a[1]+1):
        if i*R+j*G > N:
            break
        elif (N-i*R-j*G) % B == 0:
            ans += 1
print(ans)


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

int main()
{
	map<long long int, int> m;
	long long int n, max=INT_MIN;
	cin>>n;
	for(int i=0; i<n; i++)
	{
		int temp;
		cin>>temp;
		m[temp]++;
		
		if(max<m[temp]) max=m[temp];
	}
	
	if(max==1) cout<<"YES";
	else cout<<"NO";
	
	return 0;
}


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

using namespace std;

const int N = 123456;

int n, a[N];
int cnt1[N], cnt2[N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int x1 = 0, y1 = 0;
  int x2 = 0, y2 = 0;
  for (int i = 1; i <= n; i += 2) {
    cnt1[a[i]]++;
    if (cnt1[x1] < cnt1[a[i]]) {
      x1 = a[i];
    }
  }
  for (int i = 1; i <= n; i += 2) {
    if (cnt1[x2] < cnt1[a[i]] && a[i] != x1) {
      x2 = a[i];
    }
  }

  for (int i = 2; i <= n; i += 2) {
    cnt2[a[i]]++;
    if (cnt2[y1] < cnt2[a[i]]) {
      y1 = a[i];
    }
  }
  for (int i = 2; i <= n; i += 2) {
    if (cnt2[y2] < cnt2[a[i]] && a[i] != y1) {
      y2 = a[i];
    }
  }

  int res = 0;

  if (x1 == y1) {
    res = n - max((cnt1[x1] + cnt2[y2]), (cnt1[x2] + cnt2[y1]));
  } else {
    res = n - (cnt1[x1] + cnt2[y1]);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n, m, ans = 0;
	int cnt[35] = {};
	int k[35], a[35];
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> k[i];
		for(int j = 0; j < k[i]; j++){
			cin >> a[j];
			cnt[a[j]-1]++;
		}
	}
	rep(i, m){
		if(cnt[i] == n){
			ans++;
		}
	}
	cout << ans << endl;
}

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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	long long ans = 0;

	if (k - a >= 0)
	{
		ans += a;
		k -= a;
		if (k - b >= 0)
		{
			k -= b;
			if (k - c >= 0)
			{
				ans -= c;
			}
			else
			{
				ans -= k;
			}
		}
	}
	else
	{
		ans += k;
	}
	cout << ans << endl;
}

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

int main(void){
  int N; cin >> N;
  vector<pair<int, int>> X(N);
  for(int i = 0; i < N; i++){
    int x; cin >> x;
    X[i] = make_pair(x, i);
  }
  sort(X.begin(), X.end());
  vector<int> res(N);
  for(int i = 0; i < N; i++){
    if(X[i] < X[N/2]){
      res[X[i].second] = X[N/2].first;
    }else{
      res[X[i].second] = X[N/2-1].first;
    }
  }
  for(const auto& r: res){
    cout << r << endl;
  }
  return 0;
}


Measured memory_bytes: 4480
L = int(input())
k = 1
power = 4
while L >= power:
    k += 1
    power *= 2

power = 1
ans = []
for i in range(k):
    ans.append([k-i, k+1-i, 0])
    ans.append([k-i, k+1-i, power])
    power *= 2

N = k+1
l = power
rest = L - l
while rest > 0:
    power = 1
    k = 0
    while rest >= power * 2:
        power *= 2
        k += 1
    ans.append([1, N-k, l])
    l += power
    rest -= power

print(*[N, len(ans)])
for i in ans:
    print(*i)

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

int main(){
  int d,g,q,a[11]={},b[11]={},s[11]={},c[1001]={};
  cin >> d >> g;
  r(i,d)cin >> a[i] >> b[i];
  r(i,d)s[i]=a[i]+s[i-1];
  r(i,d){
    for(int j=s[i];j>0;j--){
      for(int k = 1;k<=a[i]&&k<=j;k++){
        c[j]=max(c[j],c[j-k]+k*i*100+(k==a[i])*b[i]);
      }
    }
  }
  for(q=1; c[q]<g;q++) ;
  cout << q << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, A[101010];
int SUM[101010];

void solve() {
    if (N == 0 && A[0] == 1) {
        cout << 1 << endl;
        return;
    }

    for (int i = N; i >= 0; i--) {
        SUM[i] = SUM[i + 1] + A[i];
    }

    int ans = 0;
    if (A[0] != 0) {
        ans = -1;
    } else {
        int now = 1;
        ans = 1;
        for (int i = 1; i <= N; i++) {
            if (now <= 0 || now > SUM[i]) {
                ans = -1;
                break;
            }
            now = min(SUM[i], now * 2);
            ans += now;
            now -= A[i];
        }
        if (now != 0) {
            ans = -1;
        }
    }
    cout << ans << endl;
}

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

    cin >> N;
    FOR (N + 1)
        cin >> A[i];

    solve();
    return 0;
}


Measured memory_bytes: 5228
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

int Search(long long int box) {
	long long int bag = N;
	while (bag%box == 0)bag /= box;
	return (bag%box) == 1;
}

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

	cin >> N;
	if (N == 2) {
		cout << 1 << endl;
		return 0;
	}
	long long int ans = 0;
	for (long long int i = 2; i*i <= N; i++) {
		if (N%i)continue;
		ans += Search(i);
		if (i*i == N)continue;
		ans += Search(N / i);
	}
	for (long long int i = 2; i*i <= N - 1; i++) {
		if ((N - 1) % i)continue;
		ans++;
		if (i*i == N - 1)continue;
		ans++;
	}
	cout << ans + 2 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


void solve() {
	int W, a, b; cin >> W >> a >> b;
	if (a > b)swap(a, b);
	print(max((ll)0, b - (a + W)));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
def resolve():
    n, m, c = map(int, input().split())
    bn = list(map(int, input().split()))
    print(sum([1 for _ in range(n) if sum([a * b for a, b in zip(list(map(int, input().split())), bn)]) + c > 0]))


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 62312
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    N,X,Y=mis()
    ans = [0] * N
    for d in range(1, N):
        for l in range(1, N):
            r = l + d
            if r > N:
                break
            dist = min(abs(l-r), abs(l-X)+1+abs(Y-r))
            ans[dist] += 1
    for d in range(1, N):
        print(ans[d])



main()







Measured memory_bytes: 5676
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll a,b,c,n;
vector<ll> l;
ll dfs(int k,int ap,int bp,int cp,ll point){
    if(k==n){
        if(ap==0||bp==0||cp==0)return LINF;
        //cout<<ap<<" "<<bp<<" "<<cp<<" "<<point<<"\n";
        return abs(ap-a)+abs(bp-b)+abs(cp-c)+point;
    }
    ll ans=LINF;
    if(ap==0)
    chmin(ans,dfs(k+1,ap+l[k],bp,cp,point));
    else
    chmin(ans,dfs(k+1,ap+l[k],bp,cp,point+10));
    if(bp==0)
    chmin(ans,dfs(k+1,ap,bp+l[k],cp,point));
    else
    chmin(ans,dfs(k+1,ap,bp+l[k],cp,point+10));
    if(cp==0)
    chmin(ans,dfs(k+1,ap,bp,cp+l[k],point));
    else
    chmin(ans,dfs(k+1,ap,bp,cp+l[k],point+10));
    chmin(ans,dfs(k+1,ap,bp,cp,point));
    return ans;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a>>b>>c;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        l.push_back(temp);
    }
    cout << dfs(0,0,0,0,0) << "\n";
}


Measured memory_bytes: 256