akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

vll par;
vll rnk;
void init(lli n){
    par = vll(n);
    rnk = vll(n);
    for(lli i = 0;i < n;i++) par[i] = i;
}
lli find(lli x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}
void unite(lli x,lli y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y]) par[x] = y;
    else {
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}
bool same(lli x,lli y){
    return find(x) == find(y);
}

lli n,q;
lli com,x,y;

int main(){
    cin >> n >> q;
    init(n);
    for(lli i = 0;i < q;i++){
        cin >> com >> x >> y;
        if(com == 0){
            unite(x,y);
        }else if(com == 1){
            cout << same(x,y) << endl;
        }
    }
    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  in(ll, n);
  V<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i] -= i + 1;
  sort(all(a));
  ll ans = 0;
  rep(i, n) ans += abs(a[i] - a[n / 2]);
  out(ans);
}

Measured memory_bytes: 4840
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;
int N;
string s[105];
int main() {
  cin>>N;
  REP(i,0,N)cin>>s[i];
  int a=0, u=0;
  REP(i,0,N){
    if(s[i]=="A") a++;
    else{
      u++;
      if(a < u){
        cout<<"NO"<<endl;
        return 0;
      }
    }
  }
  if(a < u || a!=u){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
  return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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 powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +511;
const LL mod=1e9+7;
LL fac[N],inv[N];
int n,m,k;
void P(){
	fac[0]=inv[0]=1;
	for(int i=1;i<=2e5;i++)fac[i]=fac[i-1]*i%mod;
	for(int i=1;i<=2e5;i++)inv[i]=powmod(fac[i],mod-2,mod);
}
LL get(int a,int b){
	if(b==0)return 1;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main(){
	ios::sync_with_stdio(false);
	P();
	cin>>n>>m>>k;
	LL ans=0;
	for(LL i=1;i<m;i++)ans=(ans+(m-i)*i%mod*n%mod*n%mod)%mod;
	for(LL i=1;i<n;i++)ans=(ans+(n-i)*i%mod*m%mod*m%mod)%mod;
	ans=ans*get(n*m-2,k-2)%mod;
	cout<<ans<<endl;
	return 0;
}

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

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  int n;
  cin >> n;
  vector<pair<int, int>> es;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < i; ++j) {
      if (i + j != (n % 2 ? n : n + 1)) {
        es.emplace_back(i, j);
      }
    }
  }
  cout << (int) es.size() << '\n';
  for (auto p : es) {
    cout << p.first << ' ' << p.second << '\n';
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

// a^n MOD を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint comb(ll n, ll a){
  mint x = 1, y = 1;
  rep(i, a){
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  comb_init();
  mint sum = modpow(2, n, MOD);
  sum -= 1;
  sum -= comb(n, a);
  sum -= comb(n, b);
  cout << sum.x << endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    long double a,p,q;
    priority_queue<long double, vector<long double>, greater<long double> > pque;
    rep(i,N){
        cin>>a;
        pque.push(a);
    }
    rep(i,N-1){
        p = pque.top(); pque.pop();
        q = pque.top(); pque.pop();
        pque.push((p + q) / 2);
    }
    cout<<fixed<<setprecision(10)<<pque.top()<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		
		int countA = 0;
		int countB = 0;
		int count_ = 0;
		
		for(int i = 0; i < A; i++) {
			if(S.substring(i, i + 1).matches("[0-9]")) {
				countA++;
			}
		}
		for(int i = A + 1; i < A + B + 1; i++) {
			if(S.substring(i, i + 1).matches("[0-9]")) {
				countB++;
			}
		}
		if(S.charAt(A) == '-') {
			count_++;
		}
		if(countA == A && countB == B && count_ == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(void){
  int mt[3]={0};
  int i,j,high;
  for(i=0;i<3;i++){
    mt[i]=-1;
  }
  for(i=0;i<10;i++){
    scanf("%d",&high);
    for(j=0;j<3;j++){
      if(mt[j]<high){
        int t=mt[j];
        mt[j]=high;
        high=t;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",mt[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y))
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;

const int N = 1e6+10 ;
const ll mod = 1e9 + 7;
typedef pair<ll,ll >PII;

vector<int >g[N];

int T,n,b,c,r;
int x1,x2,ans;

ll a[63][3];
ll x[N];

int main(){
   cin>>n;
   for(int i=1;i<=n;i++){
       cin>>x[i];
   }
   for(int i=0;i<60;i++){
       for(int j=1;j<=n;j++){
           int t = (x[j]>>i)& 0x1;
           a[i][t]++;
       }
   }
   ll sum=0;
   for(int i=0;i<60;i++){
       ll t = a[i][0]*a[i][1];
       t%=mod;
       t=t*((1ll<<i)%mod)%mod;
       t%=mod;
       sum  = (sum+t)%mod;
   }
   cout<<sum%mod;
}


Measured memory_bytes: 29440
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        p: [(u64, u64); n],
    }
    let mut ans = 0;
    let mut sum = 0;
    for p in p.iter() {
        ans += p.1;
        sum += p.0 * p.1;
    }
    ans -= 1;
    ans += (sum - 1)/ 9;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 13560
#!/usr/bin/env python

if __name__ == '__main__':
    while True:
        a, op, b = raw_input().split()
        if op == '?':
            break

        a, b = map(int, [a, b])
        print a+b if op=='+' else a-b if op=='-' else a*b if op=='*' else a/b



Measured memory_bytes: 4640
import bisect
from itertools import product

inf=float('inf')
a,b,q=map(int,input().split())
s=[-inf]+[int(input()) for i in range(a)]+[inf]
t=[-inf]+[int(input()) for i in range(b)]+[inf]
x=[int(input()) for i in range(q)]

for i in x:
    ids=bisect.bisect_right(s,i)
    idt=bisect.bisect_right(t,i)
    ans=inf
    for ss,tt in product(s[ids-1:ids+1],t[idt-1:idt+1]):
        check=min(abs(i-ss),abs(i-tt))+abs(ss-tt)
        ans=min(ans,check)
    print(ans)

Measured memory_bytes: 17052
#include<stdio.h>
#define N 100000

typedef struct{
  char n[10];
  int q;
}Data;


int main(){
  int n,q,i,j,head=0,tail,sum=0;
  Data data[N];
  
  scanf("%d%d",&n,&q);
  
  for(i=0;i<n;i++){
    scanf("%s%d",&data[i].n,&data[i].q);
  }
  
  head=0;
  tail=n;
  while(1){
    data[head].q-=q;
    sum+=q;
    if(data[head].q<=0){
      printf("%s %d\n",data[head].n,data[head].q+sum);
      sum+=data[head].q;
    }
    else {
      data[tail]=data[head];
      tail++;
    }
    head++;
    if(head==tail)break;
    if(head>=N)head=0;
    if(tail>=N)tail=0;
  }  
  return 0;
}

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


int main() {
     int n;
     cin >> n;
     vector< int> arr(n);
     for(int i=0; i< n;i++)  {
       cin >> arr[i];
     } 
     vector <int> dp(n);
     dp[0]=0;
     for(int i=1; i< n; i++)  {
       if(arr[i] <= arr[i-1])  {
         dp[i]=dp[i-1]+1;
       }
       else {
         dp[i]=0;
       }
     }
     int ans=INT_MIN;
     for(int i=0; i< n;i++)  {
          ans=max(ans,dp[i]);
     }
     cout <<  ans <<"\n";
    return 0;
}


Measured memory_bytes: 1024
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b,g):
    return a*b/g

n=input()
x=map(int,raw_input().split())
ans=[x[0]]
for i in xrange(n-1):
    g=gcd(ans[i],x[i+1])
    ans.append(lcm(ans[i],x[i+1],g))
print(ans[n-1])

Measured memory_bytes: 6432
import java.util.*;
 
 
public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
 
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      String k=sc.nextLine();
      String s[]=line.split("",0);
      int i=0;
      boolean b=false;
      while(s[i].equals("1")){
        if((i+1+"").equals(k)){
        	b=true;
          break;
        }
      	i++;
      }
      int n=Integer.parseInt(s[i]);
      if(b)System.out.println(1);
      else
        System.out.println(n);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

ll binpow(ll a,ll p){
    ll res = 1 ;
    while (p>0){
        if (p & 1)res = (res*a)%hell;
        a = (a*a)%hell;
        p = p>>1;
    }
    return res;
}

void solve(){
	//write here
    ll n;
    cin>>n;
    vector<ll>arr(n);
    rep(i,0,n)cin>>arr[i];
    ll arr_sum = 0;
    rep(i,0,n)arr_sum = (arr_sum + arr[i])%hell;
    ll arr_sq_sum = (arr_sum * arr_sum)%hell;
    ll single_sq_sum = 0;
    rep(i,0,n)single_sq_sum=(single_sq_sum + arr[i]*arr[i])%hell;
    ll val = ((arr_sq_sum - single_sq_sum + hell)%hell * binpow(2,hell-2))%hell;
    cout<<val<<endl;
	return;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

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

int N, A, cnt[200000];

int main() {
    cin >> N;
    for (int i = 1; i < N; i++) {
        cin >> A;
        cnt[A-1]++;
    }
    for (int i = 0; i < N; i++) {
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> nx(n);
  int ans = 0;
  rep(i, n){
    int in;
    cin >> in;
    nx.at(i) = in - 1;
  }
  int now = 0;
  while(now != 1){
    auto &p = nx.at(now);
    now = p;
    if(now == -1){
      ans = -1;
      break;
    }else{
      p = -1;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
k = int(input())
nums = []

def rec(d, val, nums):
    nums.append(val)
    if d == 10:
        return
    for i in range(-1, 2):
        add = val%10 + i
        if (0<= add <= 9):
            rec(d+1, val*10+add, nums)
for j in range(1,10):
    rec(1,j,nums)

nums.sort()
print(nums[k-1])

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n,cnt=0;
	cin >> n;
	vector<ll>arr(n);
	rep(i, n)cin >> arr[i];
	rep(i, n - 2) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if ((arr[i] + arr[j]) > arr[k]) {
					if ((arr[j] + arr[k]) > arr[i]) {
						if ((arr[k] + arr[i]) > arr[j]) {
							if(arr[i] != arr[k] && arr[i] != arr[j] && arr[j] != arr[k])cnt++;
						}
					}
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3628
#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;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	vector<int> data(1);
	int cnt = 0;
	rep(i, n - 1) {
		if (h[i] >= h[i + 1]) cnt++;
		else {
			data.push_back(cnt);
			cnt = 0;
		}
		if (i == n - 2) data.push_back(cnt);
	}
	sort(data.begin(), data.end());
	cout << data[data.size() - 1] << endl;
	return 0;
}

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

bool isPrime(int n)
{
    if(n<2) return false;
    for(int i=2;i*i<=n;i++) if(n%i==0) return false;
    return true;
}

int main()
{
    int Q; cin>>Q;
    int cnt=0;
    while(Q--){
        int n; cin>>n;
        if(isPrime(n)) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3068
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

main = do
  [w,a',b'] <- getInts
  let (a,b) = (min a' b', max a' b')
  print $ if b <= a+w then 0
          else b - a - w

-- util
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine


Measured memory_bytes: 380
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

long long N;

int main() {
    cin >> N;
    long long nr = 2;
    
    if (N == 2) {
        cout << 1;
        return 0;
    }
    
    for (int i = 2; (long long)i * i <= N; ++i) {
        if (N % i == 0) {
            //cout << i << endl;
            for (long long j = i; j <= N; j *= i) {
                if (N % j == 0) {
                    //cout << j << endl;
                    long long r = N / j - 1;
                    if (r % i == 0) ++nr;
                }
            }
        }
    }
    
    for (int i = 2; (long long)i * i <= N; ++i) {
        if ((N-1) % i == 0) {
    //        cout << i << endl;
            nr++;
            if ((N-1) / i != i) ++nr;
        }
    }
    
    cout << nr;
    return 0;
}




Measured memory_bytes: 256
/* ?????¢????????¨?????? 586 + 79 = 665(KiB) ??????????????????????????? */
/* ????´°??????????????§ */
#include <iostream>
#include <vector>
#include <cstdio>

struct JobRecord
{
	int staff;
	int job;
	int count;
};

int main(void)
{
	using namespace std;

	int num_of_staffs, num_of_jobs;
	cin >> num_of_staffs >> num_of_jobs;

	vector<JobRecord> v_job_record;
	vector<int> v_staff, v_job, v_count;

	/* ??\???????¨?????????????????????? */
	/* ?????§ 50000 ?????????????????? */
	/* ????????§?????¢????????¨?????? 50000(???) * 3(??????, ??????????¨????, ?????°) * 4(Bytes) = 600000(Bytes) ==> ?´?586KiB */
	while(1)
	{
		JobRecord input;
		cin >> input.staff >> input.job >> input.count;
		if( input.staff == 0 && input.job == 0 && input.count == 0 )
		{
			break;
		}
		
		/* ??\??????????????? */
		v_job_record.push_back(input);
	}

	int num_of_calc;
	cin >> num_of_calc;

	/* ???????¨???? */
	for(int calc_count = 0; calc_count < num_of_calc; calc_count++)
	{
		/* ???????¨???????????????§?????¢????????¨??????????¨??????¨?????? */
		/*   v_unit_price : 10000(??\???????¨?????????§) * 4 = 40000 Bytes */
		/*   v_salary     : 10000(????????°?????§)     * 4 = 40000 Bytes */
		/* ????¨???§ 80000 Bytes ==> ?´? 79 KiB */
		vector<int> v_unit_price(num_of_jobs);	/* ???????????¨????????? */
		vector<int> v_salary(num_of_staffs, 0);	/* ???????????¨?????????. ????????? 0 ????????????????¨???? */

		/* ??\??? */
		for(int job = 0; job < num_of_jobs; job++)
		{
			cin >> v_unit_price[job];
		}

		/* ?¨???? */
		for(int i = 0; i < v_job_record.size(); i++)
		{
			/* ???????????\???????¨??????? 1????????????????????§?????????????????????????????¨???????????? 0??????????????????????????? */
			int staff      = v_job_record[i].staff;
			int job        = v_job_record[i].job;
			int count      = v_job_record[i].count;
			int unit_price = v_unit_price[ job - 1 ];
			
			v_salary[ staff - 1 ] += unit_price * count;
		}
		
		/* ?????? */
		for(int i = 0; i < num_of_staffs; i++)
		{
			if( i != 0 )
			{
				cout << " ";
			}
			cout << v_salary[i];
		}
		cout << endl;
	}

	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s,t;
	cin >>s >>t;
	int ans = 0;
	
	rep(i, sz(s)) if(s[i] != t[i]) ans++;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

vector<int> graph[2510];
vector<int> rgraph[2510];
bool visit[2510];
bool rvisit[2510];

void dfs(int s) {
	stack<int> sta;
	sta.push(s);
	while(!sta.empty()) {
		int from = sta.top();
		sta.pop();
		visit[from] = true;
		for(auto to : graph[from]) {
			if(visit[to]) continue;
			sta.push(to);
		}
	}
	return;
}

void rdfs(int s) {
    stack<int> sta;
    sta.push(s);
    while(!sta.empty()) {
        int from = sta.top();
        sta.pop();
        rvisit[from] = true;
        for(auto to : rgraph[from]) {
            if(rvisit[to]) continue;
            sta.push(to);
        }
    }
    return;
}   

int main() {
	int n, m, p;
	cin >> n >> m >> p;
	tuple<int, int, int> edge[5010];
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		edge[i] = make_tuple(a, b, p - c);
		graph[a].push_back(b);
		rgraph[b].push_back(a);
	}

	rep1(i, n) visit[i] = rvisit[i] = false;
	dfs(1);
	rdfs(n);
	bool path[2510];
	rep1(i, n) path[i] = visit[i] & rvisit[i];

	int dist[2510];
	rep1(i, n) dist[i] = INF;
	bool update = true;
	int count = 0;
	dist[1] = 0;
	while(update) {
		update = false;
		rep(i, m) {
			int from, to, cost;
			tie(from, to, cost) = edge[i];
			if(!path[from]) continue;
			if(!path[to]) continue;
			if(dist[to] > dist[from] + cost) {
				update = true;
				dist[to] = dist[from] + cost;
			}
		}
		count++;
		if(count > n) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << max(-dist[n], 0) << endl;
}


Measured memory_bytes: 640
import java.util.*;
import static java.lang.System.out;

import java.awt.image.IndexColorModel;
public class Main{
   static Scanner sc = new Scanner(System.in);
   public static void main(String[] args){
      long N = sc.nextLong();
      ArrayList<Integer> list = new ArrayList();
      String[] str = String.valueOf(N).split("");
      int length = str.length;
      int[] array = createInt(str,length);
      list.add(plusN(array,length));

      boolean flag = length == 1;
      list.add(squat(length-1,array));
      System.out.println(Math.max(list.get(0),list.get(1)));

      // for(int i=length-1;i>=0;i--){
      //    if(!flag && i != 0){
      //       array[i] = 9;
      //    }else{
      //       array[0] = array[0] - 1 ;
      //    }
      //    list.add(plusN(array,length));
      // }
      

      // int max = 0;
      // for(int i=0;i<=length;i++){
      //    max = max < list.get(i) ? list.get(i) : max;
      // }
      // System.out.println(max);
    
   }
   static int squat(int length,int[] array){
      return array[0] + length * 9 -1;
   }
   static int[] createInt(String[] str,int length){
      int[] array = new int[length];
      int i = 0;
      for(String s: str){
         array[i++]  = Integer.parseInt(s);
      }
      return array;
   }
   static int plusN(int[] str,int length){
      int count = 0;
      for(int  s: str){
         count +=s;
      }
      return count; 
   }
}

Measured memory_bytes: 21972
_, K = map(int, input().split())
S = input()

offset = int(S[0]) == (K & 1)
runs = []

prev = S[0]
run = 0
for c in S:
    if c != prev:
        runs.append(run)
        run = 0
    prev = c
    run += 1
runs.append(run)

L = len(runs)
candidates = []

prev = sum(runs[max(0, offset - K): min(L, offset + K + 1)])
candidates.append(prev)

for i in range(offset + 2, L, 2):
    now = prev
    old_left = i - 2 - K
    new_right = i + K
    if old_left >= 0:
        now -= runs[old_left]
    if old_left + 1 >= 0:
        now -= runs[old_left + 1]
    if new_right - 1 < L:
        now += runs[new_right - 1]
    if new_right < L:
        now += runs[new_right]
    prev = now
    candidates.append(prev)

print(max(candidates))

Measured memory_bytes: 6304
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ketawa(ll n) {   // nの各桁の数の和
    ll res = 0;    
    while(n != 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}
 
int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;
    exrep(i, 1, n) {
        if(a <= ketawa(i) && ketawa(i) <= b) {
            ans += i;
        }
    }
    
    out(ans);
    re0;
}

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

int main() {
  long long N,K;
  cin >> N >> K;
  vector<long long> vec(N);
  for (int i = 0;i<N;i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  long long ans = 0;
  for (int i = 0;i<N;i++) {
    if (i >= K) ans += vec.at(i);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
   	
        int N = sc.nextInt();
        double sum = 0;
        
        for(int i=0;i<N;i++) {
        	
        	double num = sc.nextDouble();
        	String type = sc.next();
        	
        	if(type.equals("JPY")) {
        		sum +=num;
        	}
        	else {
        		sum += 380000.0 * num;
        	}
        }
        System.out.println(sum);
  	}
}

Measured memory_bytes: 22612
using System;
// using System.Collections.Generic;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int N = int.Parse(arr[0]), M = int.Parse(arr[1]);
        Console.WriteLine(N * (N - 1) / 2 + M * (M - 1) / 2);
    }
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll H[100005];
//! [足場iに行くまでの]=最小コスト
ll dp[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> H[i + 1];
    }
    H[0] = H[1];

    dp[0] = dp[1] = 0;
    FOR(i, N + 1, 2)
    {
        dp[i] = std::min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]));
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
map<ll, int>mp;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	mp.clear();
	int n;
	bool ok=1;
	cin >> n;
	for(int i=1, x; i<=n; ++i){
		cin >> x;
		if(mp[x]==0)mp[x]++;
		else ok=0;
	} 
	if(ok){
		cout <<"YES\n";
	}else{
		cout <<"NO\n";
	}
} 

Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<list>
using namespace std;

int main() {

	string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	string a;
	cin >> a;

	if (ALP.find(a, 0) == string::npos) {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include<cstring>
int main(){
	char s[11];
	scanf("%s",s);
	int l=0;
	while(s[l]!='\0')l++;
	if(s[0]=='A'){
		int c=0;
		for(int i=2;i<l-1;i++){
			if(s[i]=='C'){
				if(c==0)c=i;
				else{
					printf("WA");
					return 0;
				}
			}
		}
		if(c==0){
			printf("WA");
			return 0;
		}
		for(int i=1;i<l;i++){
			if(i!=c&&(s[i]<'a'||s[i]>'z')){
				printf("WA");
				return 0;
			}
		}
		printf("AC");
		return 0;
	}
	printf("WA");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, h[100005], dp[100005];

int calc(int x) {
    if (x == n - 1) {
        return 0;
    }
    if (dp[x] != -1) {
        return dp[x];
    }
    if (x == n - 2) {
        dp[x] = abs(h[x + 1] - h[x]) + calc(x + 1); 
        return dp[x];
    }
    dp[x] = min(abs(h[x + 1] - h[x]) + calc(x + 1), abs(h[x + 2] - h[x]) + calc(x + 2)); 
    return dp[x];
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << calc(0) << "\n";
    return 0;
}

Measured memory_bytes: 7516
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int K = Integer.parseInt(scanner.next());

        List<Integer> dislikeList = IntStream.range(0, K)
                .map(v -> Integer.parseInt(scanner.next()))
                .boxed()
                .collect(Collectors.toList());

        // n 以上の整数
        for (int i = N; i < 100000; i++) {
            boolean isCompleted = true;
            String tmp = String.valueOf(i);

            for (int j = 0; j < tmp.length(); j++) {
                int d = Integer.parseInt(String.valueOf(tmp.charAt(j)));
                if (dislikeList.contains(d)) {
                    isCompleted = false;
                    break;
                }
            }

            if (isCompleted) {
                System.out.println(i);
                return;
            }
        }

        scanner.close();
    }
}


Measured memory_bytes: 33104
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> PII;
typedef pair <long long,long long> PLL;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define eps             1e-9
#define PI              acos(-1.0)

int setBit(int n,int pos) { return n = n | (1 << pos); }
int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
bool checkBit(ll n,ll pos) { return (bool)(n & (1LL << pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/


const int MAX = 2010;
//const ll INF = 20000000000000;
//const int MOD = 1000000007;

int ara[MAX];
bitset <4000001> S;

int main() {
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);

    int n,sum = 0;
    si(n);
    for(int i=1;i<=n;i++) {
        si(ara[i]);
        sum += ara[i];
    }
    sum = (sum+1)/2;
    S.set(0);
    for(int i=1;i<=n;i++) {
        S = S | (S << ara[i]);
    }

    for(int i=sum;;i++) {
        if(S[i]==1) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 2176
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();

        if(K*500 >= X){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){
   
    ll l,s;

    vector <ll> ima;
    bool flg = false;

    cin >> s;

    l = s;
    ima.push_back(l);
    ll cnt = 1;
    while(flg == false)
    {

        if(l % 2 == 0) l = l/2;
        else l = 3 * l + 1;

        for(auto t: ima)
        {
            if(t == l)
            {
                flg = true;
                break;
            }
        }

        ima.push_back(l);
        cnt++;


    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n;
    
    scanf("%lld",&n);
    
    long long int mini=1, minj=1;
    long long int c=0, min=1000000000000;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            c = (i-1)+(n/i-1);
            if(min > c){
              min = c;
            } 
        }
    } 
    
    printf("%lld\n", min);		
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<long long> A( N );
	for( int i = 0; i < N; i++ )  {
		cin >> A[i];
	}

	int ans = 0;
	for( int i = 0; i < N; i++ )  {
		while( i + 1 < N && A[i] == A[i + 1] ) i++;
		if( i + 1 < N && A[i] < A[i + 1] ) {
			while( i + 1 < N && A[i] <= A[i + 1] ) i++;
		}
		else if( i + 1 < N && A[i] > A[i + 1] ) {
			while( i + 1 < N && A[i] >= A[i + 1] ) i++;
		}
		ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 4000
#include <iostream>

using namespace std;

int x[4], y[4];

int main(void)
{
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	
	int dx = x[1] - x[0], dy = y[1] - y[0];
	x[2] = x[1] - dy, y[2] = y[1] + dx;
	x[3] = x[2] - dx, y[3] = y[2] - dy;
	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
using namespace std;

int main() {
    int n, r, ans;
    scan2Int(n, r);    
    if (n >= 10) ans = r;
    else ans = r + 100 * (10 - n);
    printInt(ans);
    return 0;
}


Measured memory_bytes: 3768
using System;
using System.Linq;

public class ALDS1_1_A{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        
        for (var i = 1; i < N; i++)
        {
            Console.WriteLine(string.Join(" ", A));
            
            var key = A[i];
            var j = i - 1;
            while (j >= 0 && A[j] > key)
            {
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = key;
        }
        
        Console.WriteLine(string.Join(" ", A));
    }
}



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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int N[mx5];

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

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;

        N[a]++;
    }

    int ans = 0;
    for(int i = 1; i <= 1e5; i++)
        ans = max(ans, N[i - 1] + N[i] + N[i + 1]);

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


Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll x=0;
void dfs(int u,vector<int>adj[],ll vis[]) {
    vis[u]=1;
    x++;
    for(auto i: adj[u]) {
        if(!vis[i])
        dfs(i,adj,vis);
    }
}
int main() {
   ll n,m,max1=0;
   cin>>n>>m;
   vector<int>adj[n+1];
   for(int i=0;i<m;i++) {
       int a,b;
       cin>>a>>b;
       adj[a].push_back(b);
       adj[b].push_back(a);
   }
   ll vis[n+1]={0};
   for(int i=1;i<=n;i++) {
       if(!vis[i]){
           x=0;
       dfs(i,adj,vis);max1=max(x,max1);}
       
   }
   cout<<max1;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

ll gcd(ll a, ll b){
   if(b == 0) return a;
   
   return gcd(b, a % b);
}

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}

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

   int a,b,k; cin >> a >> b >> k;
   vector<int> divboth;

   for(int i = min(a, b); i >= 1; --i){
      if(a % i == 0 && b % i == 0){
         --k;
         if(k == 0){
            cout << i;
            break;
         }
      }
   }
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#ifdef LOCAL
  #include "helper_funcs.hpp"
#else
  #include <bits/stdc++.h>
#endif
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define frn(i,a,b) for(ll i=a;i<b;i++)
#define rfrn(i,a,b) for(ll i=a;i>b;--i)
#define forn(i,a,b) for(ll i=a;i<=b;i++)
#define rforn(i,a,b) for(ll i=a;i>=b;--i)
#define frt(it,v) for(auto &it:v)
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define SQ(a) (a)*(a)
#define SUM(n) ((n)*(n+1))/2
// #define SqSUM(n) ((n)*(n+1)*(2*n+1))/2
// #define GMSUM(a,r,n) (a*pow(r,n)-a)/(r-1)
#define ciel(x, y) (((x) / (y)) + ((x) % (y) != 0))
#define input(v,a,b) for(ll i = a ; i<b ; i++) cin>>v[i]
#define output(v,a,b) cout<<"["<<#v<<"]: "; for(ll i = a ; i<b ; i++) cout<<v[i]<<" "; cout<<ln
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
const long long int md = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef vector<ll> v1;
typedef vector<vector<ll > > vv2;
#define M 32
#ifndef M_PI
  #define M_PI 3.14159265358979323846
#endif
typedef bitset<M> btst;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;
typedef priority_queue<int, vector<int>> max_heap;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//     indexed_set;
const ll MAX = LONG_MAX;
const ll lrg = 1000000007;

void solve()
{
  ll n;
  cin>>n;
  ll ar[n];
  ll p=1;
  ld x=0;
  input(ar,0,n);
  ll fl=0,g=0;
  frn(i,0,n)
  {
    ll pr=p;
    p = p*ar[i];
    if (ar[i]==0)
      g=1;
    if(p<pr||p>ll(1e18))
    {
      fl=1;
    }
  }
  if(g==1)
    cout<<0;
  else if(fl==1)
    cout<<-1;
  else
    cout<<p;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); 
  int t=1,cp;
  // cin>>t;
  cp=t;
  while(t--){
   // cout<<"Case #"<<cp-t<<": ";
   solve();
   cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
ll fact[N+2];
void precompute()
{
	fact[0]=1;
	rep(i,1,N)
		fact[i]=(fact[i-1]*i)%hell;
}
ll ncr(ll n,ll r)
{
	if(r>n)
		return 0;

	ll haha=fact[n];
	ll hihi=fact[r]*fact[n-r];
	hihi%=hell;
	hihi=power(hihi,hell-2,hell);
	haha*=hihi;
	haha%=hell;
	return haha;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll n;cin>>n;
	precompute();
	if(n<3) {
		cout<<0<<endl;
		return 0;
	}

	ll maxi = n/3;
	ll ans=0;
	rep(i,1,maxi+1) {
		ll to_make = n - (i*3);
		ans+= ncr(i+to_make-1,i-1);
		//test2(i,ans);
		ans%=hell;
	}
	cout<<ans<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    string tmp;

    unordered_map<string, int> s;
    set<string> l;

    rep(i, n) {
        cin >> tmp;
        s[tmp]++;
        l.insert(tmp);
    }

    int max_cnt = 0;
    for (auto itr = l.begin(); itr != l.end(); itr++) {
        max_cnt = max(max_cnt, s[*itr]);
    }

    for (auto itr = l.begin(); itr != l.end(); itr++) {
        if (s[*itr] == max_cnt) cout << *itr << endl;
    }

    return 0;
}

Measured memory_bytes: 34504
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100010;
int n,a[N],b[N],c[N];
ll f1[N],f2[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	int i=1,j=1;
	for(i=1;i<=n;i++){
		while(c[j]<=b[i]&&j<=n) j++;
		f1[i]=n-j+1;
	}
	i=1,j=1;
	for(int i=n;i>=1;i--) f1[i]+=f1[i+1];
	for(i=1;i<=n;i++){
		while(b[j]<=a[i]&&j<=n) j++;
		f2[i]=f1[j];
	}
	ll ans=0;
	for(int i=1;i<=n;i++) ans+=f2[i];
	cout<<ans;
}

Measured memory_bytes: 2944