akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n,i;
  int *ai;
  long long int max,min,sum;

  scanf("%d",&n);
  ai=(int *)malloc(sizeof(int)*n);

  sum=0;
  for(i=0;i<n;i++){
    scanf("%d ",&ai[i]);
    if(i==0){
      max=ai[i];
      min=ai[i];
    }
    if(max<ai[i]) max=ai[i];
    if(min>ai[i]) min=ai[i];

    sum+=ai[i];
  }

  printf("%ld %ld %ld\n",min,max,sum);

  return 0;

}


Measured memory_bytes: 2096
{-# LANGUAGE BangPatterns #-}

import qualified Data.List as L

import Debug.Trace

main :: IO ()
main = do
    n <- readLn
    print
        . L.foldl' (*%) 1
        . map (succ.length)
        . L.group
        . L.sort
        $ concatMap primeFactors [1..n]

(*%) :: Int -> Int -> Int
x *% y = x * y `rem` 1000000007

smallPrimes :: (Integral i) => [i]
smallPrimes = 2 : [ n | n<-[3,5..46337], all ((>0).rem n) $ takeWhile (\x->x*x<=n) smallPrimes]
{-# SPECIALIZE smallPrimes :: [Int] #-}

primeFactors :: (Integral i) => i -> [i]
primeFactors n | n < 2 = []
primeFactors n = go n smallPrimes
  where
    go !n pps@(p:ps)
        | n < p * p = [n]
        | r > 0     = go n ps
        | otherwise = p : go q pps
      where
        (q, r) = quotRem n p
    go n [] = [n]
{-# SPECIALIZE primeFactors :: Int -> [Int] #-}

Measured memory_bytes: 5036
/*input
4
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=2*acos(0);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}

// default code end
const ll maxn=1000005;
const ll maxlg=__lg(maxn)+2;
pii arr[maxn];
bool cmp(pii a,pii b){
    return a.f-a.s>b.f-b.s;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    bool b[300010];
    vector<ll> v,ans(n);
    REP1(i,300000){
        if(i%2==0||i%3==0){
            v.push_back(i);
        }
    }
    if(n==3){
        cout<<"2 5 63"<<endl;
        return 0;
    }
    ll cnt=0;
    REP(i,n-2){
        ans[i]=v[i];
        b[v[i]]=true;
        cnt+=v[i];
    }
    for(int i=n-2;i<v.size();i++){
        if(cnt%2==0){
            if(v[i]%2==0){
                ans[n-2]=v[i];
                b[v[i]]=true;
                cnt+=v[i];
                break;
            }
        } else{
            if(v[i]%2==1){
                ans[n-2]=v[i];
                b[v[i]]=true;
                cnt+=v[i];
                break;
            }
        }
    }
    for(ll i:v){
        if(b[i]||i%2==1)continue;
        if(cnt%3==0){
            if(i%3==0){
                ans[n-1]=i;
                break;
            }
        }
        else if(cnt%3==1){
            if(i%3==2){
                ans[n-1]=i;
                break;
            }
        }
        else if(cnt%3==2){
            if(i%3==1){
                ans[n-1]=i;
                break;
            }
        }
    }
    REP(i,n){
        cout<<ans[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

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

#define int long long
#define MOD 1000000007

int f[10000010];
void init(){
    f[0] = 1;
    for(int i = 1;i < 10000010;i++){
        f[i] = f[i-1] * i % MOD;
    }
}

int pow_mod(int a, int b){
    int ans = 1;
    while(b != 0){
        if(b & 1) ans = (ans * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }

    return ans;
}

int combi(int n, int r){
    return f[n] * pow_mod(f[r], MOD-2) % MOD * pow_mod(f[n-r], MOD-2) % MOD;
}


signed main(){
    init();
    int w, h;
    cin >> w >> h;

    int y = 2*h-w;
    if(y % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    y /= 3;

    int x = w-y;
    if(x % 2 != 0){
        cout << 0 << endl;
        return 0;
    }

    x /= 2;

    if(y < 0 || x < 0){
        swap(h, w);
        int y = 2*h-w;
        if(y % 3 != 0){
            cout << 0 << endl;
            return 0;
        }
        y /= 3;

        int x = w-y;
        if(x % 2 != 0){
            cout << 0 << endl;
            return 0;
        }
        x /= 2;
    }

    if(x < 0 || y < 0){
        cout << 0 << endl;
        return 0;
    }



    cout << combi(x+y, x) << endl;
    return 0;
}


Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cntB=0,cntR=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            cntR++;
        }else{
            cntB++;
        }
    }
    if(cntR>cntB){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	S_num, c_num = tin()
	#s = input()
	if c_num <= S_num * 2:
		return c_num // 2
	
	c_num -= S_num*2
	return S_num + (c_num // 4)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62028
#include"bits/stdc++.h"
using namespace std;

long long five[201];

long long p5(int i) {
  if (five[i]) return five[i];
  else {
    long long tmp = i * i;
    tmp *= tmp;
    tmp *= i;
    five[i] = tmp;
    return tmp;
  }
}

void Main() {
  long long X;
  cin >> X;

  for (int i = 0; i <= 200; i++) {
    for (int j = 0; j <= 200; j++) {
      if (p5(j) - p5(i) == X) {
        cout << j << " " << i << endl;
        return;
      } else if (p5(j) + p5(i) == X) {
        cout << j << " " << -i << endl;
        return;
      }
    }
  }
}

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



Measured memory_bytes: 3652
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define INF 200000000

using namespace std;

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

vector<int> G[100000];
vector<int> et, depth, id;

struct ST
{
	vector<pii> data;
	int n;
	int segn;

	ST(int v,int k):n(v)
	{
		for (segn = 1; segn < (n * 2 - 1); segn *= 2);
		data.assign(2 * segn, make_pair(INF, -1));
		for (int i = 0; i < k; i++)
		{
			data[segn + i] = make_pair(depth[i], et[i]);
		}
		for (int i = segn - 1; i >= 1; --i)
		{
			data[i] = min(data[i * 2], data[i * 2 + 1]);
		}
	}

	pii find(int s, int t, int l, int r)
	{
		if (r == -1)
		{
			r = segn;
		}
		if (t <= s || r == 0)
		{
			return make_pair(INF, -1);
		}
		if (t - s == r)
		{
			return data[l];
		}

		return min(find(s, min(t, r / 2), l * 2, r / 2), find(max(0, s - (r / 2)), t - (r / 2), l * 2 + 1, r / 2));
	}
};

void ET(int n, int p, int& eti, int d)
{
	id[n] = eti;
	et[eti] = n;
	depth[eti] = d;
	eti++;

	for (auto& e : G[n])
	{
		if (e != p)
		{
			ET(e, n, eti, d + 1);
			et[eti] = n;
			depth[eti] = d;
			eti++;
		}
	}
}

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

	int n;
	cin >> n;

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

		for (int j = 0; j < k; j++)
		{
			int c;
			cin >> c;
			G[i].emplace_back(c);
		}
	}

	et = vector<int>(n * 2 - 1);
	depth = vector<int>(n * 2 - 1);
	id = vector<int>(n);

	int eti = 0;
	ET(0, -1, eti, 0);

	ST st(n,eti);

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		int u, v;
		cin >> u >> v;

		printf("%d\n", st.find(min(id[u], id[v]), max(id[u], id[v]) + 1, 1, -1).second);
	}

	return 0;
}


Measured memory_bytes: 21992
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/*
  クラスカルのアルゴリズム
  - グラフの辺を，重みの昇順にsortする
  - 辺の重みの小さいものから順に，辺が互いに素の集合をつなぐものの場合MSTに追加する
  O[ElogE]  //辺のsort の計算量

  union_findのライブラリを利用する
*/

class DisjointSet{
  public:
    vector<int> rank, p;  //rank:根の高さ， ｐ:代表
    DisjointSet(int size){
      rank.resize(size, 0);
      p.resize(size, 0);
      for(int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

    bool same(int x, int y){
      return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
      link(findSet(x), findSet(y));
    }

    void link(int x, int y){
      if( rank[x] > rank [y]){
        p[y] = x;
      }
      else{
        p[x] = y;
        if(rank[x] == rank[y]){
          rank[y]++;
        }
      }
    }

    int findSet(int x){
      if( x != p[x]){
        p[x] = findSet(p[x]);
      }
      return p[x];
    }

};

class Edge {
  public:
  int source, target, cost;
  Edge(int source = 0, int target = 0, int cost = 0):
  source(source), target(target), cost(cost){}
  bool operator < ( const Edge & e) const{
    return cost < e.cost;
  }
};

int kruskal(int N, vector<Edge> edges){
  int totalCost = 0;
  //辺を昇順にソート
  sort(edges.begin(), edges.end());

  DisjointSet dset = DisjointSet(N + 1);

  //DS初期化
  for(int i = 0; i < N; i++) dset.makeSet(i);

  int source, target;
  for(int i = 0; i < edges.size(); i++){
    Edge e = edges[i];
    if( !dset.same(e.source, e.target)) {
      //MST.push_back(e);
      totalCost += e.cost;
      dset.unite( e.source, e.target);
    }
  }

  return totalCost;

}

int main(){
  int N, M, cost;
  int source, target;

  cin >> N >> M;
  vector<Edge> edges;

  REP(i,M){
    cin >> source >> target >> cost;
    edges.push_back(Edge(source, target, cost));
  }

  cout << kruskal( N, edges ) << endl;

  return 0;
}



Measured memory_bytes: 5180
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

bool check(vector< vector<string> >& a, char c, int m) {
	int n = a.size();
	for (int x = 0; x < n; x++)
		for (int y = 0; y < n; y++)
			for (int z = 0; z < n; z++)
				for (int dx = -1; dx <= 1; dx++)
					for (int dy = -1; dy <= 1; dy++)
						for (int dz = -1; dz <= 1; dz++)
							if (dx || dy || dz) {
								bool flag = true;
								for (int i = 0; i < m; i++) {
									int _x = x + i * dx, _y = y + i * dy, _z = z + i * dz;
									if (_x < 0 || _x >= n || _y < 0 || _y >= n || _z < 0 || _z >= n || a[_x][_y][_z] != c) {
										flag = false;
										break;
									}
								}
								if (flag) return true;
							}
	return false;
}

int main() {
	for (;;) {
		int n, m, p; cin >> n >> m >> p;
		if (n == 0) break;
		vector<int> X(p), Y(p);
		for (int i = 0; i < p; i++) cin >> X[i] >> Y[i];
		vector< vector<string> > a(n, vector<string>(n, string(n, ' ')));
		int i;
		for (i = 0; i < p; i++) {
			int x = X[i] - 1, y = Y[i] - 1;
			int z;
			for (z = 0; a[x][y][z] != ' '; z++);
			char c = (i % 2 == 0 ? 'B' : 'W');
			a[x][y][z] = c;
			if (check(a, c, m)) break;
		}
		if (i < p) cout << (i % 2 == 0 ? "Black" : "White") << ' ' << i + 1 << endl;
		else cout << "Draw" << endl;
	}
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {
    public static int selection_sort(int a[], int n) {
        int cnt = 0;
        for (int i = 0; i < n - 1; i++) {
            int min = a[i];
            int minflag = i;
            for (int j = i + 1; j < n; j++) {
                if (min > a[j]) {
                    min = a[j];
                    minflag = j;
                }
            }
            if (minflag != i) {
                int temp = a[i];
                a[i] = a[minflag];
                a[minflag] = temp;
                cnt++;
            }
        }
        return cnt;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();
        int ans = selection_sort(a, n);
        for (int i = 0; i < n; i++) {
            System.out.print(a[i]);
            if (i < n - 1)
                System.out.print(" ");
        }
        System.out.println();
        System.out.println(ans);
        sc.close();
    }

}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int N;cin>>N;
    int sum=0,n=N;

    while(n>0){
        sum+=n%10;
        n/=10;
    }

    if(N%sum==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;

}


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

vector<double> pv(1001);

double fp(int a){
	static bool f = true;
	if(f){
		f = false;
		double sum = 0;
		for(int i=1;i<=1000;++i){
			sum += i;
			//pv[i] = sum;
			pv[i] = sum/i;
		}
		/*
		for(int i=1;i<10;++i){
			cout << pv[i] << " ";
		}cout << endl;*/
	}
	
	return pv[a];
}

int main(){
	int n,k;
	cin >> n >> k;
	
	vector<int> data(n);
	for(int i=0;i<n;++i){
		cin >> data[i];
	}
	
	
	double res = 0;
	double tmp_sum = 0;
	double tmp_index_sum = 0;
	for(int i=0;i<k;++i){
		tmp_sum += fp(data[i]);
		//tmp_index_sum += data[i];
	}
	res =tmp_sum;
	//cout << tmp_sum/tmp_index_sum <<endl;
	
	for(int i=k;i<n;++i){
		tmp_sum = tmp_sum - fp(data[i-k]) + fp(data[i]);
		res = max(res,tmp_sum);
		//tmp_index_sum = tmp_index_sum - data[i-k] + data[i];
		//res = max(res,tmp_sum/tmp_index_sum);
		//cout << i << " " << tmp_sum/tmp_index_sum <<" " << tmp_sum << " " << tmp_index_sum<<endl;
	}
	
	std::cout << fixed<< std::setprecision(15) << res <<endl;
	return 0;
}



Measured memory_bytes: 1024
import numpy as np

N=int(input())	
listA = list(map(int,input().split()))

minA = min(listA)

while True:
    minA = min(listA)
    minApos = np.argmin(listA)
    listA = [x % minA for x in listA]
    listA[minApos] = minA
    listA= [x for x in listA if x >0]
    if len(set(listA))==1:
        print(minA)
        break

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

const int MOD = 1e6 + 3;

int fact[MOD];

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

int pot(int x, int y) {
	int res = 1;
	for (; y; y /= 2) {
		if (y % 2)
			res = mul(res, x);
		x = mul(x, x);
	}
	return res;
}

int divide(int x, int y) {
	return mul(x, pot(y, MOD - 2));
}

int calc(int x, int n) {
	if (x > 0 && x + n <= MOD)
		return divide(fact[x + n - 1], fact[x - 1]);
	return 0;
}

int solve(int x, int d, int n) {
	if (d)
		return mul(pot(d, n), calc(divide(x, d), n));
	return pot(x, n);
}

int main() {
	fact[0] = 1;
	for (int i = 1; i < MOD; i++)
		fact[i] = mul(fact[i - 1], i);
		
	int Q;
	scanf("%d", &Q);
	while (Q--) {
		int x, d, n;
		scanf("%d%d%d", &x, &d, &n);
		printf("%d\n", solve(x, d, n));
	}
	
	return 0;
}

Measured memory_bytes: 5116
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, d[202020], m, t[202020];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> t[i];
	}
	
	sort(d, d+n);
	sort(t, t+m);
	int j = 0;
	for(int i = 0; i < m; i++){
		while(d[j] < t[i] && j < n){
			j++;
		}
		if(t[i] != d[j]){
			cout << "NO" << endl;
			return 0;
		}
		j++;
	}
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>
#define int long long
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

using namespace std;

void Fast_Read_Out()
{
	ios_base::sync_with_stdio(0);
	cin.tie(), cout.tie();
}

void Random()
{
	unsigned int seed;
	asm("rdtsc" : "=A" (seed));
	srand(seed);        
}

unsigned int Time()
{
	 unsigned int time = clock() / 1000.00;
	 return time;
}

const int inf = (1e9) + 123;
const int N = 2e5 + 123;
const int K = 21;

int pref[N], a[N], xorr[N];

main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif 
	Random();
	Fast_Read_Out();
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i], pref[i] = pref[i - 1] + a[i], xorr[i] = (xorr[i - 1] ^ a[i]);
	int res = 0;
	for(int i = 1; i <= n; i++)
	{
		int l = i, r = n;
		while(l + 1 < r)
		{
			int mid = l + r >> 1;
			if(pref[mid] - pref[i - 1] == (xorr[mid] ^ xorr[i - 1])) l = mid;
			else r = mid;
		}
		if(pref[r] - pref[i - 1] == (xorr[r] ^ xorr[i - 1])) res += (r - i + 1);
		else res += (l - i + 1);
	}
	cout << res << endl;
	#ifdef JUDGE
//		cout << Time() << endl;
	#endif
}
// Easy Peasy Lemon Squeezy

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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n;
	cin >> n;
	if(n < 4){
		 cout << "No" << endl;
		 return 0;
	}
	if(n % 4 == 0 || n % 7 == 0 || n % 11 == 0){
		cout << "Yes" << endl;
		return 0;
	}
	for(int i=n, j =n ;i>=4, j>=7;i-=4, j-=7){
		if(i % 7 == 0 || j % 4 == 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rsz resize()
#define lb lower_bound
#define ub upper_bound
#define br cout << endl

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); } 
int bit(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bit(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }

template<typename T>
void leftShift(vector<T> &v, ll k) { k %= sz(v); if(k < 0) k += sz(v); rotate(v.begin(), v.begin() + k, v.end()); }
template<typename T>
void rightSift(vector<T> &v, ll k) { leftShift(v, sz(v) - k); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

inline int nxt() {
	int x;
	cin >> x;
	return x;
}

inline ll nxtll() {
	ll x;
	cin >> x;
	return x;
}

void pr() {}
void sc() {}

template <typename Head, typename... Tail>
void pr(Head H, Tail... T) { cout << H << " "; pr(T...); }

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#ifndef LOCAL
string to_string(__int128 x) {
	string s = "";
	bool neg = 0;
	if(x < 0) { s += "-"; neg = 1; }
	if(!x) s += '0';
	while(x) {
		int rem = x % 10;
		s += to_string(rem);
		x /= 10;
	}
	reverse(s.begin() + neg, s.end());
	return s;
}
#endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
*/

bool good(ll n, ll d) {
	if(d == 1) return 0;
	debug(n, d);
	while(n % d == 0) n /= d;
	n %= d;
	return n == 1;
}

void solve() {
	ll n = nxtll();
	ll ans = 0;
	for(ll d = 1; d * d <= n; d++) {
		if(n % d == 0) {
			if(good(n, d)) ans++;
			if(d != (n / d) && good(n, n / d)) ans++;
		}
	}
	for(ll d = 1; d * d <= n - 1; d++) {
		if((n - 1) % d == 0) {
			if(good(n, d)) ans++;
			if(d != ((n - 1) / d) && good(n, (n - 1) / d)) ans++;
		}
	}
	cout << ans;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	bool flg=true;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		if(a%2!=0) flg=false;
	}
	if(flg) cout << "second" << endl;
	else cout << "first" << endl;
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int n;
vector<int> a[2];
int dp1[105], dp2[105];
int ans = 0;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    a[0].resize(n);
    a[1].resize(n);
    REP(i, 2){
        REP(j, n) cin >> a[i][j];
    }
    
    dp1[0] = 0;
    REP(i, n){
        dp1[i+1] = dp1[i] + a[0][i];
    }
    REP(i, n){
        dp2[1] += a[1][i];
    }
    FOR(i, 1, n){
        dp2[i+1] = dp2[i] - a[1][i-1];
    }
    FOR(i, 1, n+1){
        ans = max(dp1[i] + dp2[i], ans);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#define fr first
#define sc second
#define INF (2 << 28)
using namespace std;

typedef pair<int, int> iiP;
struct edge{
  int to, cost; edge(){}
  edge(int to, int cost):to(to), cost(cost){}
}; 
			      
vector<vector<edge> > Graph;

int n, m;

void init(int n){
  
  Graph.resize(0), Graph.resize(n);

}

int Prim(){
  
  int ret = 0;
  vector <int> used(n, 0); 
  priority_queue<iiP, vector<iiP>, greater<iiP> > que;
  que.push(iiP(0, 0));
  while(!que.empty()){
    iiP p = que.top(); que.pop();
    if(used[p.sc]++) continue;
    ret += p.fr;
    for(int i = 0; i < Graph[p.sc].size(); i++){
      que.push(iiP(Graph[p.sc][i].cost, Graph[p.sc][i].to));
    }
  }
  return ret;

}

int main(){
  
  while(cin >> n, n){
    cin >> m;
    init(n);

    for(int i = 0; i < m; i++){
      int a, b, c; scanf("%d, %d, %d", &a, &b, &c);
      Graph[a].push_back(edge(b, c/100-1));
      Graph[b].push_back(edge(a, c/100-1));
    }

    cout << Prim() << endl;
  }

}

Measured memory_bytes: 1548
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
using namespace std;

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

typedef long long ll;
typedef unsigned long long int ulli;

const ll INF = ll(1e18) + 1;

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

ulli gcd(ulli a, ulli b) {
	return (b <= 0) ? a : gcd(b, a % b);
}

ulli lcm(ulli a, ulli b) {
	return a * b / gcd(a, b);
}



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



void Main()
{
	ll n, m, ac = 0; cin >> n >> m;
	vector<ll> pena(n);
	vector<bool> a(n,false);
	rep(i, m) {
		char str[3];
		ll p;
		cin >> p >> str;
		p--;
		if (a[p]) continue;
		if (str[0] == 'A') {
			a[p] = true;
			ac++;
		}else{
			pena[p]++;
		}
	}
	ll pen = 0;
	rep(i, n) if (a[i]) pen += pena[i];

	cout << ac << " " << pen << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
typedef long long ll;

ll M = 1000000007;
int main() {
	int n, m, i, s, t,u,v,w[111111][3];
	priority_queue<pair<pair<int, int>, int >> que;
	cin >> n >> m;
	vector<vector<int>> list(n+1);
	for (i = 0; i < m; i++) {
		cin >> u >> v;
		list[u].push_back(v);
	}
	for (i = 1; i <= n; i++) {
		w[i][0] = 0;
		w[i][1] = 0;
		w[i][2] = 0;
	}
	cin >> s >> t;
	que.push(make_pair(make_pair(0, 0), s));
	while (!que.empty()) {
		int a = que.top().first.first, b = que.top().first.second, c = que.top().second;
		if (c == t&&b==0) {
			cout << -a << endl;
			return 0;
		}
		if (w[c][-b] == 0) {
			for (auto itr = list[c].begin(); itr != list[c].end();itr++) {
				if (-b == 2)
					que.push(make_pair(make_pair(a - 1, 0), *itr));
				else
					que.push(make_pair(make_pair(a, b-1), *itr));
			}
			w[c][-b]++;
		}
		que.pop();
	}
	cout << "-1" << endl;
}

Measured memory_bytes: 6912
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

ll m=1e9+7;

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

int main()
{ios_base::sync_with_stdio(false);
ll n,k;
cin>>n>>k;

ll dp[10004];
vll div;

for(ll i=1;i*i<=n;i++)
{
	if(n%i==0)
	{
		div.pb(i);
		if(i*i!=n)div.pb(n/i);
	}
}

sort(all(div));

rep(i,0,div.size()-1)
{
	dp[i]=p(k,(div[i]+1)/2);
	rep(j,0,i-1)
	{
		if(div[i]%div[j]==0)
		dp[i]-=dp[j];
		dp[i]%=m;
	}
	if(dp[i]<0)dp[i]+=m;
}
ll ans=0;
rep(i,0,div.size()-1)
{
	if(div[i]%2==0)
	ans+=dp[i]*(div[i]/2);
	else
	ans+=dp[i]*div[i];
	ans%=m;
}
ol(ans);

return 0;
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  int m = n*(n-1)/2;

  vvi M(n);
  rep(i, n){
    rep(j, n-1){
      int a;cin>>a;a--;
      M[i].pb(a);
    }
  }
  dump_2d(M, n, n-1);

  vector<pii> nodes;
  rep(i, n)rep(j, i+1, n){
    nodes.pb(mp(i, j));
  }

  map<pii, vector<pii>> g;
  // map<pii, int> h;
  vvi h(n, vi(n));
  rep(i, n){
    rep(j, 1, n-1){
      int pre = M[i][j-1];
      int to = M[i][j];
      g[mp(min(i, pre), max(i, pre))].pb(mp(min(i, to), max(i, to)));
      h[i][to]++;
      h[to][i]++;
    }
  }
  dump(g);

  //入次数が0の頂点の集合
  stack<pii> st;

  //入次数が0の頂点であればstに追加
  each(i, nodes) if(h[i.first][i.second] == 0) st.push(i);
  
  //ソートされた後のグラフ
  set<pii> finish;

  //stがなくなるまでループ
  int cnt = 0;
  while(sz(finish)<m){
    stack<pii> nex;
    while(st.size()) {
      //stの集合のから一つ取り出す
      pii i = st.top(); st.pop();
      finish.insert(i);

      rep(k, sz(g[i])){
        //隣接する頂点の入次数をマイナス1
        auto j = g[i][k];
        h[j.first][j.second]--;
        h[j.second][j.first]--;
        if (h[j.first][j.second]==0) nex.push(j);
      }
    }

    cnt++;
    dump(cnt, finish);

    //これによって入次数が0になればstに追加
    st = (nex);
    if (sz(st)==0) break;
  }
  
  //ansを順に出力
  dump(finish);
  if (sz(finish)==m) {
    cout << cnt << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 125940
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


int main() {
    ll n; cin >> n;
    V A(n+1), B(n);
    rep(i, 0, n+1) cin >> A[i];
    rep(i, 0, n) cin >> B[i];

    ll ans = 0;
    rep(i, 0, n){
        if(B[i] >= A[i]){
            ans += A[i];
            if(B[i]-A[i] <= A[i+1]){
                ans += B[i]-A[i];
                A[i+1] -= B[i]-A[i];
            }else{
                ans += A[i+1];
                A[i+1] = 0;
            }
        }
        else ans += B[i];
    }

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

Measured memory_bytes: 1792
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, C;
    std::cin >> N >> C;

    struct R {
        int64_t t;
        int64_t c;
    };

    struct P {
        int64_t s;
        int64_t t;
        int64_t c;
    };

    std::vector<P> progs;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t s, t, c;
        std::cin >> s >> t >> c;
        progs.push_back({s, t, c});
    }

    std::vector<R> recs;

    std::sort(std::begin(progs), std::end(progs),
              [](const auto& a, const auto& b) {
                  return a.s < b.s;
              });

    for (auto p: progs) {
        // 同じチャンネル
        auto pos = std::find_if(std::begin(recs), std::end(recs), [&p](auto x) {
                return x.c == p.c;
            });
        if (pos != recs.end()) {
            pos->t = p.t;
            continue;
        }

        // 違うチャンネル空き開いてるならどれ使っても同じ
        pos = std::find_if(std::begin(recs), std::end(recs), [&p](auto x) {
                return x.t < p.s;
            });
        if (pos != std::end(recs)) {
            pos->t = p.t;
            pos->c = p.c;
            continue;
        }

        // 新規追加
        recs.push_back({p.t, p.c});
    }

    std::cout << recs.size() << std::endl;

    return 0;
}


Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define maxn 100050
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=min(b,d)-max(a,c);
	if(ans<0) ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

int main(){
  double a,b,n;
  cin >> a >> b >> n;
  double s=b;
  if(b>n)s=n+1;
  cout << floor(a*(s-1)/b)-a*floor((s-1)/b);
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}


//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   int  n;cin>>n;
   vector<P> p(n);
   rep(i,n)cin>>p[i].fi>>p[i].se;
   vector<P> pp(n);
   rep(i,n){
      pp[i].fi=p[i].fi+p[i].se;
      pp[i].se=p[i].fi-p[i].se;
   }
   int xmax=-INF,xmin=INF,ymax=-INF,ymin=INF;
   rep(i,n){
      chmax(xmax,pp[i].fi);
      chmin(xmin,pp[i].fi);
      chmax(ymax,pp[i].se);
      chmin(ymin,pp[i].se);
   }
   cout<<max(xmax-xmin,max(ymax-ymin,0))<<endl;
}

Measured memory_bytes: 6372
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

void printVector(vector<int> vec);

int main() {
	int N, K;
	cin >> N >> K;
	vector<unsigned long int> health;
	health.reserve(N);
	for (int i = 0; i < N; i++) {
		unsigned long int H;
		cin >> H;
		health.push_back(H);
	}
	sort(health.begin(), health.end());
	unsigned long int sum = 0;
	for (int i = 0; i < N - K; i++) {
		sum += health[i];
	}
	cout << sum << endl;
}

void printVector(vector<int> vec) {
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << endl;
}

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

int main()
{
	long long int n, x = 0, y = 0;
	long long int ans = 0;
	cin >> n;
	int a[n];
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	for(int i = 0 ; i < n ; i++)
	{
		if(a[i] == a[i + 1])
		{
			if(x == 0)
				x = a[i];
			else
			{
				y = a[i];
				ans = x * y;
				break;
			}
			i++;
		}
	}
	if(x && y)
		cout << ans << endl;
	else
		cout << "0" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int m,d;
    cin>>m>>d;
    int cnt=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int d1=j%10;
            int d2=j/10;
            if(d1>=2 && d2>=2 && d1*d2==i){
                cnt++;
            }

        }
    }

    cout<<cnt<<endl;





    return 0;
}


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

using namespace std;
using ll = long long;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

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


int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;

    return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {	
	int n = 0, m = 0;
	string s; cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'R') {
			++n;
		}
		else {
			n = 0;
		}
		m = max(n, m);
	}
	cout << m << endl;
}   

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

    // int t; cin >> t;
    // while(t--) 
        solve();
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <list>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;

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


Measured memory_bytes: 640
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-16 07:22:17
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  int n = s.size();

  string ans = "";

  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else {
      if (ans.empty()) {
        continue;
      } else {
        ans.pop_back();
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,x; cin>>a>>b>>x;
	cout << (a<=x&&a+b>=x ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;
    for(int k = 0; k < (n - 1); k++) {
      int t = 0;
      int[] a = new int[26];
      int[] b = new int[26];
      for(int i = 0; i <= k; i++) {
        a[s.charAt(i) - 'a']++;
      }
      for(int i = k + 1; i < n; i++) {
        b[s.charAt(i) - 'a']++;
      }
      for(int i = 0; i < 26; i++) {
        if((a[i] > 0) && (b[i] > 0)) t++;
      }
      ans = Math.max(ans, t);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <cstdio>
#define maxn (ll)1e5+10
#define mod (ll)1e9+7
using namespace std;
typedef long long ll;
int n,m;
ll x[maxn],y[maxn],sumx,sumy,ans,tmp;
ll c(ll a) {
	// return c(a,2)
	ll res=a*(a-1)/2;
	res%=mod;
	return res;
}
int main() {
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%lld",&x[i]);
	for (int i=1;i<=m;i++)
		scanf("%lld",&y[i]);
	sumx=0LL;
	for (int i=1;i<n;i++) {
		tmp=c(n)-c(i)-c(n-i);
		tmp%=mod;
		tmp*=(x[i+1]-x[i]);
		tmp%=mod;
		sumx+=tmp;
		sumx%=mod;
		
	}
	if (n==2)
		sumx=x[2]-x[1];
	sumy=0LL;
	for (int i=1;i<m;i++) {
		tmp=c(m)-c(i)-c(m-i);
		tmp%=mod;
		tmp*=(y[i+1]-y[i]);
		tmp%=mod;
		sumy+=tmp;
		sumy%=mod;
	}
	if (m==2)
		sumy=y[2]-y[1];
	ans=sumx*sumy;
	ans%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int GetDigit(unsigned long long num,int d){

    return log(num) / log(d) + 1;
}

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

    cout << GetDigit(N, K) << endl;

    return 0;
}


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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    long a[16][16];
    for(int i=0; i < n; ++i) for(int j=0; j < n; ++j) cin >> a[i][j];

    long S[1<<16] = {0};
    for(int bit = 1; bit < (1<<n); ++bit) 
        for(int i = 0; i < n; ++i) 
            for(int j = i + 1; j < n; ++j) 
                if(bit & (1<<i) && bit & (1<<j)) S[bit] += a[i][j];

    long dp[1<<16] = {0};
    for(int bit = 1; bit < (1<<n); ++bit) 
        for(int i = bit; i; i = (i-1) & bit) dp[bit] = max(dp[bit], S[i] + dp[bit ^ i]);

    cout << dp[(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 1280