akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

using namespace std;

int main() {
  long long a, b;
  scanf("%lld %lld", &a, &b);
  long long ans = 0;
  while (a <= b && a % 4 != 0) {
    ans ^= a;
    ++a;
  }
  while (b >= a && b % 4 != 3) {
    ans ^= b;
    --b;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int ketawa(int a) {
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> a >> b >> s; int cnt = 0;
	rep(i, a + b + 1) {
		if (i == a && s[i] == '-')cnt++;
		else if (i != a && s[i] != '-')cnt++;
	}
	Cout(Yes(cnt == a + b + 1));

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long long int a, b;
	
	scanf("%lld %lld", &a, &b);
	
	if(a*b<0||a*b==0){
		printf("Zero\n");
		return 0;
	}
	
	if((a<0&&b<0)&&(b-a)%2==0){
		printf("Negative\n");
		return 0;
	}
	
	printf("Positive\n");
	return 0;
}


Measured memory_bytes: 128
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N, A; cin >> N >> A;
    vi X(N+1); FOR(i, 1, N+1) cin >> X[i];
    
    const int NMAX=50, XMAX = 50;
  
    vector<vvl> dp(NMAX + MGN, vvl(NMAX + MGN, vl(NMAX * XMAX + MGN, 0)));

    dp[0][0][0] = 1;
    FOR(i, 1, N + 1) dp[i][0][0] = 1;

    for(int i=1; i<=N; i++) {
        for(int j=1; j<=i; j++) {
            for(int k=0; k <= j*XMAX; k++) {
                if (k >= X[i]) {
                    dp[i][j][k] += dp[i - 1][j - 1][k - X[i]];
                }
                dp[i][j][k] += dp[i - 1][j][k];
            }
        }
    }

    ll ans = 0;
    FOR(j, 1, N+1) ans += dp[N][j][A*j];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 72192
import sys
def input(): return sys.stdin.readline().strip()
def MAP(): return map(int, input().split())

n, a, b = MAP()
print(abs(a - b) // 2 if not (a - b) % 2 else abs(a - b) // 2 + min(min(a, b) - 1, n - max(a, b)) + 1)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int n;
pair<int,int> a[222222];
pair<int,int> y[222222];
multiset<int> s,s2;
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		a[i] = make_pair(x,y);
	}
	sort(a,a+n);
	for(int i=0; i<n; i++){
		s.insert(a[i].first);
		s2.insert(a[i].second);
	}

	for(int i=0; i<n; i++)
		y[i] = make_pair(a[i].second, i);
	sort(y,y+n);

	long long int res = (long long int)((*s2.rbegin() - *s2.begin())) * ((*s.rbegin()) - (*s.begin()));
	for(int i=n-1; i>=0; i--){
		int id = y[i].second;
		if(id == 0)break;
		s.erase(s.find(a[id].first));
		s.insert(a[id].second);

		s2.erase(s2.find(a[id].second));
		s2.insert(a[id].first);
		res = min(res, (long long int)((*s2.rbegin() - *s2.begin())) * ((*s.rbegin()) - (*s.begin())));
	}
	cout << res <<endl;
	return 0;
}


Measured memory_bytes: 22144
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int d = sc.nextInt();
      int n = sc.nextInt();
      int num = 100;
      num = (int) Math.pow(num, d);
      
      if(n % 100 == 0) n++;
      System.out.println(num * n);
  }
}


Measured memory_bytes: 23636
searchWord=input()
sentences=[]

while True:
    line=input().split(" ")
    if line==["END_OF_TEXT"]:
        break
    else:
        sentences.append(line)

count=0

for line in sentences:
    for word in line:
        lowerWord=word.lower()
        if searchWord==lowerWord:
            count+=1

print(count)




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

int main()
{
    long long I5[6209];
    long long i;
    int X;

    for(i = 0; i < 6209; i++) {
        I5[i] = i * i * i * i * i;
        //cout << i << ":" << I5[i] << endl;
    }

    cin >> X;

    int A, B;
    for(A = 0; A < 6209; A++) {
        for(B = 0; B < 6209; B++) {
            if(+I5[A]+I5[B] == X) {
                //cout << "A+B" << endl;
                B *= -1;
                goto out;
            } else if(+I5[A]-I5[B] == X) {
                //cout << "A-B" << endl;
                goto out;
            } else if(-I5[A]+I5[B] == X) {
                //cout << "-A+B" << endl;
                A *= -1;
                B *= -1;
                goto out;
            } else if(-I5[A]-I5[B] == X) {
                A *= -1;
                goto out;
            }
        }
    }
out:

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define txt                        \
    freopen("ip.txt", "r", stdin); \
    freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define quickie                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define div2(a) (!(a & 1))
#define deb(x) cout << (#x) << " " << (x) << "\n";
#define newl cout << "\n"
#define all(s) s.begin(), s.end()
#define pi 3.14159265358979323846
#define fp(x) fixed << setprecision(x) <<
template <class T>
T mod(T a)
{
    if (a < 0)
    {
        a += 1000000007;
    }
    return a % 1000000007;
}
template <class T>
T addmod(T a, T b)
{
    return (mod(a) + mod(b)) % 1000000007;
}
template <class T>
T prodmod(T a, T b)
{
    return (mod(a) * mod(b)) % 1000000007;
}
template <class T>
T bin_exp(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b % 2 == 0)
        res = bin_exp(a * a, b / 2);
    else
    {
        res *= a;
        temp = bin_exp(a, --b);
    }
    return res * temp;
}
template <class T>
T bin_expmod(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b % 2 == 0)
        res = bin_expmod(prodmod(a, a), b / 2);
    else
    {
        res = prodmod(a, res);
        temp = bin_exp(a, --b);
    }
    return prodmod(res, temp);
}

template <class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template <class T>
int sumAllInts(T n)
{
    int a = 1;
    int su = 0;
    while (n)
    {
        su += n % 10;
        n /= 10;
    }
    return su;
}
template <class T>
void split(char c, T s)
{
    int n = s.size();
    int i = 0;
    while ((cout << s[i], i += 1) && (i < n) && (cout << c << ' '))
        ;
}
void solve()
{
    //first we make ALl possible SCC make_pair
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    if (m < 2 )
    {
        cout << 0;
        return;
    }
    m /= 2;
    if (m > n)
    {
        //S are less
        ll fix = n;
        m -= n;
        m /= 2;
        fix += m;
        cout << fix;
    }
    else
    {
        cout << m;
    }
}
int main()
{
    quickie;
    //txt;
    int t = 1;
    while (t--)
    {
        solve();
        newl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<long long > prime_factorize(long long N) {
    vector<long long> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;

        // divide as much as you can
        while (N % a == 0) {
            N /= a;
        }

        // push the result
        res.push_back(a);
    }
    // last num (if the lasting n is prime number and not 1)
    if (N != 1) res.push_back(N);
    return res;
}

int main() {
    ll n,a; cin >> n;
    vector<ll> m;
    vector<ll> c(1000001,0);
    set<ll> st;
    bool flag1 = true, flag2 = true;

    rep(i,n){
        cin >> a;
        m = prime_factorize(a);
        rep(j,m.size()){
            st.insert(m[j]);
            c[m[j]] ++;
        }
    }

    for(auto itr = st.begin(); itr != st.end(); ++itr) {
        if(c[*itr] > 1) flag1 = false;
        if(c[*itr] >= n) flag2 = false;
    }

    if(flag1 && flag2) cout << "pairwise coprime";
    else if(flag2) cout << "setwise coprime";
    else cout << "not coprime";


}


Measured memory_bytes: 14800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

bool is_prime(int64_t x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

int main() {

  ll X;
  cin >> X;

  ll test = X;

  while (1) {
    if (is_prime((int64_t)test)) {
      break;
    }
    else {
      test++;
    }
  }

  cout << test << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 7;
typedef long long LL;
int main() {
    LL x, k, d;
    cin >> x >> k >> d;
    LL nd = abs(x) / d;
    LL s = min(nd, k);
    k -= s;
    if (x < 0) x += s * d;
    else x -= s * d;
    k %= 2;
    if (k) {
        if (x < 0) {
            cout << abs(x + d) << endl;
        }
        else {
            cout << abs(x - d) << endl;
        }
    }
    else {
        cout << abs(x) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

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

int h, w;
vector<string> s;

struct Info{
    int x, y, cnt, flag;
    Info(int x, int y, int cnt, int flag) : x(x), y(y), cnt(cnt), flag(flag) {}
};

vector<vector<int>> ans(105, vector<int>(105, INF));

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

    cin >> h >> w;
    s.resize(h);
    for(int i = 0; i < h; ++i)  cin >> s[i];
    queue<Info> que;
    if(s[0][0] == '.'){
        que.push(Info(0, 0, 0, 0));
        ans[0][0] = 0;
    }
    else{
        que.push(Info(0, 0, 1, 1));
        ans[0][0] = 1;
    }
    while(!que.empty()){
        Info info = que.front();
        que.pop();
        int x = info.x, y = info.y, cnt = info.cnt, flag = info.flag;
        // cerr << x << " " << y << " " << cnt << " " << flag << "\n";
        for(int i = 0; i < 2; ++i){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w)  continue;
            if(s[nx][ny] == '.'){
                if(cnt < ans[nx][ny]){
                    que.push(Info(nx, ny, cnt, 0));
                    ans[nx][ny] = cnt;
                }
            }
            else{
                if(flag == 0){
                    if(cnt + 1 < ans[nx][ny]){
                        que.push(Info(nx, ny, cnt + 1, 1));
                        ans[nx][ny] = cnt + 1;
                    }
                }
                else{
                    if(cnt < ans[nx][ny]){
                        que.push(Info(nx, ny, cnt, 1));
                        ans[nx][ny] = cnt;
                    }
                }
            }
        }
    }
    // for(int i = 0; i < h; ++i){
    //     for(int j = 0; j < w; ++j){
    //         cerr << ans[i][j] << " ";
    //     }
    //     cerr << "\n";
    // }
    cout << ans[h - 1][w - 1] << endl;
}

Measured memory_bytes: 512
N = int(input())
Alst = list(map(int, input().split()))
Blst = [0]*(N+1)
num = 0
for i in Alst:
    num = num + Blst[i]
    Blst[i] += 1

for i in Alst:
    k = Blst[i] -1
    print(num - k)

Measured memory_bytes: 32344
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
using namespace std;

typedef pair<int, int> P;

typedef struct{
	int id;
	int solve;
	int time;
	int penal[20];
}Team;


vector< P > ssolve;
int main(void){

	while(1){
		int m, t, p, r;
		Team teams[100];
		cin >> m >> t >> p >> r;
		if(m == 0 && t == 0 && p == 0 && r == 0) break;

		ssolve.clear();
		for(int i=0; i<100; i++){
			teams[i].id = i;
			teams[i].solve = 0;
			teams[i].time = 0;
			for(int j=0; j<20; j++){
				teams[i].penal[j] = 0;
			}
		}

		for(int i=0; i<r; i++){
			int tm, tt, tp, tj;
			cin >> tm >> tt >> tp >> tj;

			tt--;
			if(tj == 0){
				teams[tt].solve++;  
				teams[tt].time += tm;
				if(teams[tt].penal[tp] != 0) {
					teams[tt].time += teams[tt].penal[tp];
					teams[tt].penal[tp] = 0;
				}
			}else{
				teams[tt].penal[tp] += 20;
			}

		}

		for(int i=0; i<t-1; i++){
			for(int j=t-1; j>i; j--){
				if(teams[j].solve > teams[j-1].solve){
					Team tmp = teams[j];
					teams[j] = teams[j-1];
					teams[j-1] = tmp;
				}else if(teams[j].solve == teams[j-1].solve && teams[j].time < teams[j-1].time){
					Team tmp = teams[j];
					teams[j] = teams[j-1];
					teams[j-1] = tmp;
				}else if(teams[j].solve == teams[j-1].solve && teams[j].time == teams[j-1].time && teams[j].id > teams[j-1].id){
					Team tmp = teams[j];
					teams[j] = teams[j-1];
					teams[j-1] = tmp;
				}
			}
		}

		for(int i=0; i<t; i++){
			printf("%d", teams[i].id + 1);
			if(i + 1 != t){
				if(teams[i+1].solve != teams[i].solve){
					printf(",");
				}else if(teams[i+1].solve == teams[i].solve && teams[i+1].time != teams[i].time){
					printf(",");
				}else{
					printf("=");
				}
			}
		}
		puts("");

	}


	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

void merge_sort(int x[], int n)
{
	static int y[200002] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, a[200001], b[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(b[i]));
	
	int j, k, bit[31] = {1}, lower[2][31][200002], ans = 0, tmp;
	for (i = 1; i < 31; i++) bit[i] = bit[i-1] << 1;
	for (i = 1; i <= N; i++) {
		for (j = 0; j < 30; j++) {
			if ((a[i] | bit[j]) == a[i]) ans ^= bit[j] * (N % 2);
			if ((b[i] | bit[j]) == b[i]) ans ^= bit[j] * (N % 2);
			lower[0][j][i] = a[i] % bit[j+1];
			lower[1][j][i] = b[i] % bit[j+1];
		}
	}
  
	int l, r;
	for (j = 0; j < 30; j++) merge_sort(&(lower[1][j][1]), N);
	for (k = 0; k < 30; k++) {
		for (i = 1, tmp = 0; i <= N; i++) {
			if (lower[0][k][i] + lower[1][k][N] < bit[k+1]) continue;
			for (l = 1, r = N; l < r; ) {
				if (lower[0][k][i] + lower[1][k][(l+r)/2] >= bit[k+1]) r = (l + r) / 2;
				else l = (l + r) / 2 + 1; 
			}
			tmp += (N - l + 1) % 2;
		}
		ans ^= bit[k+1] * (tmp % 2);
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 50432
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    reverse(h.begin(), h.end());

    for(int i = 1; i < n; i++){
        if(h[i - 1] + 1 < h[i]){
            cout << "No" << endl;
            return 0;
        }

        if(h[i - 1] < h[i]){
            h[i]--;
        }

    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <cmath>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;



lint 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;

bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> r;

    cout <<  r * r    << endl;


//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
ret = 0
for i in 0..a
  for j in 0..b
    for k in 0..c
      ret += 1 if (i * 10 + j * 2 + k) * 50 == x
    end
  end
end

puts ret


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int calc(ll n, ll i) {
  if(n < i) return n;
  else if(n % i == 0) return calc(n/i, i);
  else return n%i;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n; cin >> n;
  if(n == 2) {
    cout << 1 << endl;
    return 0;
  }

  set<ll> st;
  for(ll i=2;i*i<=n-1;++i) {
    if((n-1) % i == 0) {
      st.insert(i);
      if(i*i != n-1) st.insert((n-1)/i);
    }
  }

  for(ll i=2;i*i<=n;++i) {
    if(n%i == 0) {
      st.insert(i);
      if(i*i != n) st.insert(n/i);
    }
  }

  ll cnt = 0;
  for(auto &e: st) {
    cnt += calc(n, e) == 1;
  }
  cout << cnt + 2 << endl;
}


Measured memory_bytes: 512
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B = i2nn()
    n = min(A * N, B)
    print(n)

main()


Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n = 3;
int a[3][3];
int b[3], c[3];
int solve() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= j) {
				int sum = a[i][j] - c[j];
				if (j != 0 && b[i] != sum)
					return 0;
				b[i] = a[i][j] - c[j];
			}
			else {
				int sum = a[i][j] - b[i];
				if (i > 0 && sum != c[j]) 
					return 0;
				c[j] = a[i][j] - b[i];
			}
		}
	}
	if (b[2] + c[2] == a[2][2])
		return 1;
	return 0;
}
signed main() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i <= a[0][0]; i++) {
		b[0] = i, c[0] = a[0][0] - i;
		if (solve()) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	getchar(); getchar();
}

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

using namespace std;

int main(){
    string s;
    deque<char> r;
    int q,t,f, n = 0;
    char c; 
    cin >> s;
    cin >> q;
    for(int i = 0; i < s.length();i++){
        r.push_back(s[i]);
    }
    while(q--){
        cin >> t;
        if(t == 1){
            n++;
        }
        else{
            cin >> f >> c;
            if(n % 2 == 0){
                if(f == 1)r.push_front(c);
                else r.push_back(c);
            }
            else{
                if(f == 1)r.push_back(c);
                else r.push_front(c);
            }
        }
    }
    while(!(r.empty())){
        if(n % 2 == 0){
            cout << r.front();
            r.pop_front();
        }
        else{

            cout << r.back();
            r.pop_back();
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = sc.nextInt();
        
        int[] array = new int[n];
        if (s == 1000000000) {
            Arrays.fill(array, 999999999);
        } else {
            Arrays.fill(array, 1000000000);
        }
        
        for (int i = 0; i < k; i++) {
            array[i] = s;
        }
        
        for (int i = 0; i < n; i++) {
            System.out.print(array[i]);
            
            if (i != n-1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 55544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll N = 1000;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<char> se;
	string s;
	cin>>s;
	FOR(i,0,s.size()){
		se.insert(s[i]);
	}
	if(se.size()==s.size())pri("yes");
	else pri("no");
}

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

int main(void)
{
    long long A,B;
    cin >> A >> B;
    long long FA = A, FB = B;
    long long temp = 0, x = 0;
    if (B>A){
        x = B;
        B = A;
        A = x;
    }
    while(A%B !=0){
        temp = B;
        B = A % B;
        A = temp;
    }
    long long AB;
    AB = FA * FB/B;
    cout << AB;
    
}


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

int main(){
    int a;
    char s[4];
    scanf("%s",&s);
    for(int i=0;i<4;i++){
        if(s[i]=='+'){
            a++;
        }else{
            a--;
        }
    }
    printf("%d",a);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#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, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int D, T, S;
    void input() { cin >> D >> T >> S; }
    void output() {
        bool res = (D <= S * T);
        string s = res ? "Yes" : "No";
        cout << s << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main(){
    int a, b;
    cin >> a >> b;
    
    string a_, b_;

    a_ = to_string(a);
    b_ = to_string(b);
    
    string a_ans, b_ans;
    for(int i = 0; i < b; i++){
        a_ans += a_;
    }

    for(int i = 0; i < a; i++){
        b_ans += b_;
    }
    if(a > b){
        cout << b_ans << endl;
    }else{
        cout << a_ans << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define max(a, b) ((a)>(b)?(a):(b))
int N;
long long K, A[100100], b[50], ans = 0;
int main(){
	scanf("%d%lld", &N, &K);
	for(int i=0; i<N; i++){
		scanf("%lld", A+i);
		int j=0;
		ans += A[i];
		long long tmp = A[i];
		while(tmp){
			b[j++] += (tmp&1);
			tmp >>= 1;
		}
	}
	for(int i=0; i<40; i++){
		long long tmp = 0;
		if(((K+1)>>i)&1){
			for(int j=0; j<40; j++){
				if(j < i){
					if(b[j] < (N-b[j])) tmp += (1ll<<j) * (N-b[j]);
					else tmp += (1ll<<j) * b[j];
				}else if(j == i){
					tmp += (1ll<<j) * b[j];
				}else {
					if(((K+1)>>j)&1){
						tmp += (1ll<<j) * (N-b[j]);
					}else {
						tmp += (1ll<<j) * b[j];
					}
				}
			}
		}
		ans = max(ans, tmp);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2468
x,n=map(int, input().split())
if n==0:
    print(x)
else:
    p = list(map(int,input().split()))
    if x not in p:
        print(x)
    else:
        x1=x+1
        x2=x-1
        for i in range(n):
            if x2 not in p:
                print(x2)
                break;
            elif x1 not in p:
                print(x1)
                break;
            x1=x1+1
            x2=x2-1


Measured memory_bytes: 9192
#include<cstdio>
#include<cctype>

int main(){
    char ch;
    int alpha[26] = {};
    /*
    while(cin >> ch){

    }
    */
    while(scanf("%c", &ch) != EOF){
        ch = tolower(ch);
        if(isalpha(ch)){
            for(int i=0; i<=25; i++){
                if(ch - 'a' == i) alpha[i]++; 
            }
        }
    }
    for(int i=0; i<=25; i++) printf("%c : %d\n", 'a' + i, alpha[i]);
    
    return 0;
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=1e9+7;
const int M=1e6+10;
const int N=2e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int n,m,k,T;
ll ans[N];
int col[N];
int vis[N],sz[N],s[N];
bool vv[N];
vector<vector<int> > e;
ll f(int x) {return 1ll*x*(x+1)/2;}
void dfs(int x,int _fa) {
	int i,j;
	sz[x]=1;
	ll res=0,temp=vis[col[x]];
//	vis[col[x]]=0;
	for(auto y:e[x]) {
		if(y==_fa) continue;
		vis[col[x]]=0;
		dfs(y,x);
		res+=vis[col[x]];
		sz[x]+=sz[y];
		s[col[x]]-=vis[col[x]];
		ans[col[x]]+=f(sz[y]-vis[col[x]]);
	}
	vis[col[x]]=sz[x]+temp;
	s[col[x]]+=sz[x];
}
int main() 
{
    int i,j;
	n=read();
	e.resize(n+1);
	for(i=1;i<=n;i++) {
		col[i]=read();
		vv[col[i]]=1;
	}

	for(i=1;i<=n-1;i++) {
		int x=read(),y=read();
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,0);
	for(i=1;i<=n;i++) {
		printf("%lld\n",f(n)-f(n-vis[i])-ans[i]);
	}
    return 0;
}


Measured memory_bytes: 37700
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
map<int,int>have;
int dfs(int val)
{
    if(!val)return 0;
    if(have[val])return have[val];
    int q[6]={val/2,val/2+1,val/3,val/3+1,val/5,val/5+1};
    int w[6]={2,2,3,3,5,5};
    int num=INF;
    fu(i,0,5)
    {
        if(q[i]<val)
        {
            num=min(num,dfs(q[i])+(int)min((ld)abs(val-q[i]*w[i])*a[1]+a[w[i]],(ld)(val-q[i])*a[1]));
        }
    }
    return have[val]=num;
}
main()
{
    IOS
    cin>>t;
    fut(o)
    {
        cin>>n;
        cin>>a[2]>>a[3]>>a[5]>>a[1];
        have.clear();
        out(dfs(n));
    }
    return 0;
}


Measured memory_bytes: 4716
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,K;
long long in[N];
long long A[N];
bool ck(int x){
	A[0]=x*2;
	for(int i=1;i<=n;i++)A[i]=in[i]-A[i-1];
	return A[n]>=A[0];
}
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&in[i]),in[i]*=2;
	int l=0,r=1e9;
	while(l<=r){
		int mid=(l+r)>>1;
		if(ck(mid))l=mid+1;
		else r=mid-1;
	}
	ck(l-1);
	for(int i=0;i<n;i++)printf("%lld ",A[i]);puts("");
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
typedef long long LL;
int sz=0;
LL IN(void)
{
  LL x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  LL N=IN();int str[12];
  while(N){N--;str[sz++]='a'+N%26;N/=26;}
  for(int i=sz-1;i>=0;i--)printf("%c",str[i]);
}

Measured memory_bytes: 1520
MOD = 10 ** 9 + 7
n = int(input())
x = list(map(int, input().split()))
ans = 1
cnt = 0
for i in range(n):
    if x[i] < (i - cnt) * 2 + 1:
        ans *= i - cnt + 1
        cnt += 1
        ans %= MOD
for i in range(n - cnt):
    ans *= (i + 1)
    ans %= MOD
print(ans)

Measured memory_bytes: 14716
n = int(input())
a = list(map(int, input().split()))
ol = []
el = []

for i in range(n):
    if i%2 == 0:
        ol.append(a[i])
    else:
        el.append(a[i])

if n%2 == 0:
    for i in el[::-1]:
        print(i, end = " ")
    for i in ol:
        print(i, end = " ")
else:
    for i in ol[::-1]:
        print(i, end = " ")
    for i in el:
        print(i, end = " ")

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e17

ll n;
ll a[311111];
ll s1[311111],s2[311111];
priority_queue<ll,vector<ll>,greater<ll> > q1;
priority_queue<ll> q2;

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n*3)cin>>a[i];
  rep(i,n){
    s1[n-1]+=a[i];
    q1.push(a[i]);
  }
  repl(i,n,n*3){
    s1[i]=s1[i-1];
    s1[i]+=a[i];
    q1.push(a[i]);
    s1[i]-=q1.top();
    q1.pop();
  }
  //repl(i,n-1,n*3)dbg(s1[i]);

  reverse(a,a+n*3);
  rep(i,n){
    s2[n-1]+=a[i];
    q2.push(a[i]);
  }
  repl(i,n,n*3){
    s2[i]=s2[i-1];
    s2[i]+=a[i];
    q2.push(a[i]);
    s2[i]-=q2.top();
    q2.pop();
  }
  //repl(i,n-1,n*3)dbg(s2[i]);

  ll res=-INF;
  repl(i,n-1,2*n){
    maxch(res,s1[i]-s2[3*n-2-i]);
  }
  cout<<res<<endl;

	return 0;
}


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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

string s;

void read() {

}

void solve() {
  for(int i = 0; i < 3; ++i) {
    cin >> s;
    cout << s[i];
  }
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t;           // PLEASE REMOVE IT IF NEEDED
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,a[105];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int minn=99999999;
	for(int i=a[0];i<=a[n-1];i++){
		int sum=0;
		for(int j=0;j<n;j++){
			sum+=(i-a[j])*(i-a[j]);
		}
		if(sum<minn){
			minn=sum;
		}
	}
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int N, K;
        char S[50];

        scanf("%d %d",&N ,&K);
        scanf("%s" ,S);

        switch(S[K-1]){
                case 'A':
                        S[K-1] = 'a';
                        break;
                case 'B':
                        S[K-1] = 'b';
                        break;
                case 'C':
                        S[K-1] = 'c';
                        break;
                default:
                        break;
        }

        printf("%s",S);

}

Measured memory_bytes: 128
function Main(s) {
  var s = s.split("\n");
  var n = parseInt(s[0], 10);
  var a = s[1].split(" ").map(e => parseInt(e, 10));
  var max = 0;
  for (var i of a) max = i > max ? i:max;
  var backet = new Array(max + 2).fill(0);
  for (var i = 0; i < n; i++) {
    backet[a[i] - 1]++;
    backet[a[i]]++;
    backet[a[i] + 1]++;
  }
  max = 0;
  for (var i of backet) max = i > max ? i:max;
  console.log(max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29208
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

template<typename T>
T ceil(T x, T y){
    return (x + (y - 1)) / y;
}

int N;
int a[200001];
int box[200001];
int main(void){
    cin >> N;
    rep(i,N) scanf("%d", &a[i+1]);
    for(int i = N;i > N/2;i--) box[i] = a[i];

    for(int i = N/2;i>0;i--){
        int tmp = 0;
        for(int j = i;j<=N;j+=i){
            tmp += box[j];
        }
        box[i] = (tmp % 2) ^ a[i];
    }

    int count = 0;
    for(int i = 1;i<=N;i++) if (box[i] > 0) count++;
    cout << count << endl;
    for(int i = 1;i<=N;i++) if (box[i] > 0) cout << i << endl;;

    return 0;
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b, c, d; cin >> a >> b >> c >> d;
  if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }
  else if(a+b>c+d){
    cout<<"Left"<<endl;
  }
  else{
    cout<<"Right"<<endl;
  }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S, T;
int main() {
    cin >> S >> T;
    if (S.size() >= T.size()) {
        for (int i = 0; i <= S.size() - T.size(); i++) {
            if (T == S.substr(i, T.size())) {
                printf("%d\n",i);
            }
        }
    }
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
string S,T;
cin>>N;
cin>>S>>T;
string ans="";

rep(i,N){
    ans+=S.substr(i,1)+T.substr(i,1);
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int i;
  char S[30];
  bool used[26];
  for (i = 0; i < 26; i++) {
    used[i] = false;
  }
  scanf("%s", S);
  int N = strlen(S);
  for (i = 0; i < N; i++) {
    int alphabet = (int)S[i] - 97;
    used[alphabet] = true;
  }
  /*for (i = 0; i < 26; i++) {
    printf("(%d:%d) ", i, used[i]);
    }*/
  if (N < 26) {
    int not_used;
    for (i = 0; i < 26; i++) {
      if (!used[i]) {
	not_used = i + 97;
	break;
      }
    }
    string ans = string(S);
    ans += (char)not_used;
    const char* ans_char = ans.c_str();
    printf("%s", ans_char);
  } else {
    int gyakuten = 0;
    for (i = 25; i >= 1; i--) {
      if (S[i] > S[i-1]) {
	gyakuten = i;
	break;
      }
    }
    //printf("gyakuten:%d\n", gyakuten);
    if (gyakuten == 0) {
      printf("-1");
    } else {
      for (i = gyakuten; i < 26; i++) {
	int alphabet = (int)S[i] - 97;
	used[alphabet] = false;
      }
      /*for (i = 0; i < 26; i++) {
	printf("(%d:%d) ", i, used[i]);
	}*/
      int not_used;
      for (i = 0; i < 26; i++) {
	if (!used[i] && i+97 > (int)S[gyakuten-1]) {
	  not_used = i + 97;
	  break;
	}
      }
      //printf("not_used = %d\n", not_used);
      string ans = string(S);
      ans.erase(ans.begin() + gyakuten - 1, ans.begin() + 26);
      ans += (char)not_used;
      const char* ans_char = ans.c_str();
      printf("%s", ans_char);
    }
  }
  return 0;
}


Measured memory_bytes: 256
N=int(input())
li=[]

for n in range(N):
  li.append(int(input()))

li.sort()
S=sum(li)


while S%10==0 and li!=[]:
  if li[0]%10==0:
    li.pop(0)
  else:
    S-=li.pop(0)
if li==[]:
  print(0)
else:
  print(S)

Measured memory_bytes: 3060
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(n-2):
    flag1 = p[i] < p[i+1] and p[i+1] < p[i+2]
    flag2 = p[i+2] < p[i+1] and p[i+1] < p[i]
    if flag1 or flag2:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
S = int(input())
x1 = int((S-1)/1000000000)+1
y2 = 1000000000
x2 = (1000000000 - S) % 1000000000
y1 = 1
if x1*y2-x2*y1 != S:
    x1 -= 1
print('{} {} {} {} {} {}'.format(0, 0, x1, y1, x2, y2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using sqvec = vector<vector<int>>;
int main(){
  int n;
  cin >> n;
  //sqvec a(vector<int>(n));
  int a[n], b[n], c[n];
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  int dp[n][3];
  for(int i = 0; i < n; i++){
    dp[i][0] = -1;
    dp[i][1] = -1;
    dp[i][2] = -1;
  }
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for(int i = 1; i < n; i++){
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
    dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
  }
  cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
}


Measured memory_bytes: 2560