akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}
const int N = 1e5 + 10;
int F[N], G[N];

int64 comb(int n, int m) {
  if (m < 0 || m > n) return 0;
  return (int64)F[n] * G[m] % MOD * G[n - m] % MOD;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  F[0] = G[0] = 1;
  for (int i = 1; i <= n; ++i) {
    F[i] = (int64)F[i - 1] * i % MOD;
    G[i] = power_mod(F[i], MOD - 2);
  }
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int ret = 0;
  for (int i = 1; i < n; ++i) {
    int L = i, R = n - i;
    int64 cur = comb(n, m);
    cur = (cur + MOD - comb(R, m)) % MOD;
    cur = (cur + MOD - comb(L, m)) % MOD;
    // trace(i, cur, a[i] - a[i - 1]);
    ret += cur * (a[i] - a[i - 1]) % MOD;
    ret %= MOD;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 1408
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑




int main() {
	long long a, b;
	cin >> a >> b;
	cout << mod_pow(a, b) << endl;
}


Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);


        int[] p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
        int pn = 15;

        int[] a = new int[15];
        int n = sc.nextInt();
        int res = 0;

        for(int i=2; i<=n; i++) {
            int d = i;
            for(int j=0; j<pn; j++) {
                while(d % p[j] == 0) {
                    a[j]++;
                    d /= p[j];
                }
            }
        }

        int a3 = 0;
        int a5 = 0;
        int a15 = 0;
        int a25 = 0;
        int a75 = 0;

        for(int i=0; i<pn; i++) {
            if(a[i] >= 74) a75++;
            if(a[i] >= 24) a25++;
            if(a[i] >= 14) a15++;
            if(a[i] >= 4) a5++;
            if(a[i] >= 2) a3++;
        }

        res += a75;
        res += a25 * (a3 - 1);
        res += a15 * (a5 - 1);
        res += (a5 * (a5-1) / 2) * (a3 - 2);
        System.out.println(res);

    }


}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  cout << min(a,b) << " " << max(0LL,a+b-n) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		// 1 : str[0]
		// 2 : order count Q
		// 3~ Last : order
		//
		// Order condition
		// 1) Print ab : a~b syso
		// 2) Reverse ab: a~b Reverse
		// 3) Replace ab : a~b P(str or char) Switch

		// Sample Input 1
		// abcde
		// 3
		// replace 1 3 xyz
		// reverse 0 2
		// print 1 4
		// Sample Output 1
		// xaze
		// Sample Input 2
		// xyz
		// 3
		// print 0 2
		// replace 0 2 abc
		// print 0 2
		// Sample Output 2
		// xyz
		// abc

		Scanner sc = new Scanner(System.in);

		// declear variable
		int min=0, max=0;
		String tmpStr="";

		// str input
		String str = sc.nextLine();
		// ordercount input
		int orderCntQ = sc.nextInt();

		for (int i = 0; i < orderCntQ; i++) {
			String order = sc.next();
			min = Integer.parseInt(sc.next());
			max = Integer.parseInt(sc.next());

			switch (order) {
			case "replace":
				//replace()
				tmpStr = sc.next();
				str=Order1(str, order, min, max, tmpStr);
				break;
			case "reverse":
				// substring()
				str=Order2(str, order, min, max);
				break;
			case "print":
				// charAt()
				Order3(str, order, min, max);
				break;
			}
		}
	}

	static String Order1(String str, String order, int min, int max, String tmpStr) {// clear
		// replace()
		// str = str.replace(str.substring(min,max+1), tmpStr);//sample#3~Error
		// point
		String target = "";
		String before = "";
		String after = "";
		for (int i = 0; i < min; i++) {
			before += str.charAt(i);
		}

		for (int i = min; i <= max; i++) {
			target += str.charAt(i);
		}

		for (int i = max + 1; i < str.length(); i++) {
			after += str.charAt(i);
		}

		str = before + tmpStr + after;

		return str;
	}

	static String Order2(String str, String order, int min, int max) { // Error
																		// point
		// case "reverse":

		String target = "";
		String before = "";
		String after = "";
		for (int i = 0; i < min; i++) {
			before += str.charAt(i);
		}

		for (int i = min; i <= max; i++) {
			target = str.charAt(i) + target;
		}

		for (int i = max + 1; i < str.length(); i++) {
			after += str.charAt(i);
		}

		str = before + target + after;
		return str;

	}
	static void Order3(String str, String order, int min, int max) {

		//case "print":
		for (int i = min; i <= max; i++){
			System.out.print(str.charAt(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 95488
N = int(input())
T,A =list(map(int,input().split(" "))) 
Hs = list(map(int,input().split(" ")))
ans = 0
mindiff = 10 ** 9
for i,h in enumerate(Hs):
  temp = T - h * 0.006
  if abs(temp - A ) < mindiff:
    ans = i + 1
    mindiff = abs(temp - A )
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 200100;
int n, h, ans, w, x[N], y[N], black[N];
vector <pair<int, int> > v;
int main() {
	ios_base::sync_with_stdio(false);

	cin >> h >> w >> n;
	
	ans = h;
	for(int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
		if(x[i] < y[i]) continue;
		v.push_back({x[i] + y[i], i});
	}

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

	int min_dif = 0;
	for(auto i : v) {
		if(x[i.nd] - y[i.nd] < min_dif) continue;
		if(x[i.nd] - y[i.nd] == min_dif)
			min_dif = x[i.nd] - y[i.nd] + 1;
		else
			ans = min(ans, x[i.nd] - 1);
	}

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

	

Measured memory_bytes: 3956
#Osa_k法（前処理をした後、素因数分解をO(logN)でできる）

N = int(input())
sieve = [-1] * (N+1)
#prime = []
for i in range(2, N+1):#前処理（各indexについて、割れる最小の素数）
    if sieve[i] == -1:#未探索のとき
        sieve[i] = i
        #prime.append(i)#素数列挙したいとき
        for j in range(i*i, N+1, i):
            if sieve[j] == -1:
                sieve[j] = i
#print(sieve)
#print(prime)

Ans = [1] * (N+1)
for i in range(2, N+1):
    p = sieve[i]
    cur = i
    cnt = 0
    while cur > 1:
        if cur % p == 0:
            cur //= p
            cnt += 1
        else:
            break
    if i == pow(p,cnt):#iの素因数がpのみ
        Ans[i] = i*(cnt+1)
    else:
        Ans[i] = Ans[i//(p**cnt)] * Ans[p**cnt]#それ以外の時、掛算すればOK
#print(Ans)
print(sum(Ans)-1)

Measured memory_bytes: 229132
{$mode Delphi}
uses Classes, SysUtils, Fgl;
     
type 
  pair = record first : int64; 
                second : int64;
                class operator = (p1, p2 : pair) : boolean;
                end;
  pairList = TFPGList<pair>;
  
class operator pair.=(p1, p2 : pair): boolean;
begin
  result := (p1.first = p2.first) and (p1.second = p2.second);
end;

var arr : pairList;
    n, i : integer;
    p : pair;     
    now_time : int64;
    can : boolean;

function pairCompare(const p1, p2 : pair) : int64;
begin
  if p1.first = p2.first then result := p1.second - p2.second
  else result := p1.first - p2.first;
end;

begin
  arr := TFPGList<pair>.Create();
  read(n);
  for i := 0 to n-1 do begin
    read(p.second, p.first);
    arr.Add(p);
  end;
  arr.Sort(@pairCompare);
  can := true;
  for i := 0 to n-1 do begin
    now_time := now_time + arr[i].second;
        if now_time > arr[i].first then begin
            can := false;
            break;
        end;
  end;
  if can then writeln('Yes') else writeln('No');
end.

Measured memory_bytes: 7136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			string s = cin.Next();
			int n = s.Length;
			bool ok = true;
			for (int i = 0; i < n; i++) {
				if ((i + 1) % 2 == 0) {
					if (s[i] == 'R') {
						ok = false;
					}
				} else {
					if (s[i] == 'L') {
						ok = false;
					}
				}
			}

			Console.WriteLine(ok ? "Yes" : "No");
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

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

const int mxN = 1e5;
int h[mxN], dp[mxN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	memset(dp, 0x3f, sizeof(dp));
	for(int i = 0; i < n; i++)
		cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
	}

	cout << dp[n-1] << endl;
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

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

	ll p = 1;
	reps( i, n ) {
		p = (p * i) % 1000000007;
	}

	cout << p << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO
#define endl "\n" // Since endl forces a buffer flush which slows down large I/O operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n)             \
	for (int i = 0; i < (n); i++) \
		cin >> (c)[i];
#define exit_message(s) return 0 * printf(s)
#define show(c)           \
	for (auto i : (c))      \
		cout << i << " "; \
	cout << "\n";
#define display(c, n)           \
	for (int i = 0; i < (n); i++) \
		cout << (c)[i] << " ";    \
	cout << "\n";
#define forl(i, a, n) for (int (i) = (a); (i) < (n); (i)++)
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vill;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;

ll mod_pow(ll a, ll b)
{
	if (b == 0)
		return 1LL;

	ll res = mod_pow(a, b >> 1);
	res = (res * res) % mod;
	if (b & 1LL)
		res = (res * a) % mod;

	return res;
}

const int N = 3e3 + 5;

int n;
double p[N];
double cache[N][N];

int32_t main()
{
#ifdef FASTIO
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#endif
	// freopen("in.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	memset(cache, 0, sizeof cache);

	cin >> n;
	forl(i, 0, n)
	{
		cin >> p[i];
	}

	// cache[i][j] = j heads turn up considering the first i coins.
	cache[0][0] = 1 - p[0];
	cache[0][1] = p[0];
	double ans = 0.0;
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j <= i + 1; j++)
		{
			cache[i][j] = cache[i - 1][j] * (1 - p[i]);
			if (j)
				cache[i][j] += cache[i - 1][j - 1] * p[i];
		}
	}
	for (int j = n / 2 + 1; j <= n; j++)
		ans += cache[n - 1][j];

	cout << fixed << setprecision(10) << ans << "\n";

	return 0;
}

Measured memory_bytes: 70784
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(s: String, K: Int){
    var substrings = mutableListOf<String>()
    for (i in 1..K){
        for (j in 0..s.length - i){
            substrings.add(s.slice(j until j + i))
        }
    }
    val subs = substrings.sorted().distinct()
    // println(subs)
    println(subs[K-1])
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val K = sc.next().toInt()
    solve(s, K)
}



Measured memory_bytes: 43244
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;


int main(){
    ll n;
    cin>>n;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    map<ll,ll> M;
    M[0]=1;
    ll sum=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        ans+=M[sum];
        M[sum]++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 14320
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
 
int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	int S[1002][1002] = {0};
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if(i < B and j >= A) { 
				S[i][j] = 1;
			}
			if(i >= B and j < A) { 
				S[i][j] = 1;
			}
		}	
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << S[i][j];
		}	
		cout << endl;
	}
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
using namespace std;
int n,d,a,j;
pair <int,int> mas[N];
vector <pair<int,int> > v;
ll ans,sum,zum;
int main(){

	ios::sync_with_stdio(0);
	
	cin>>n>>d>>a;
	for(int i=1;i<=n;i++){
		cin>>mas[i].f>>mas[i].s;
	}
	sort(mas+1,mas+1+n);
	
	for(int i=1;i<=n;i++){
		for(j;j<v.size();j++){
			if(v[j].f>=mas[i].f)break;
			zum-=v[j].s;
		}
		mas[i].s-=zum;
		if(mas[i].s<=0)continue;
		sum=mas[i].s/a;
		if(mas[i].s%a!=0)sum++;
		v.pb({mas[i].f+2*d,sum*a});
		zum+=sum*a;
		ans+=sum;
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 3956
import numpy as np
from collections import deque

H,W = map(int, input().split())

maze = []
for h in range(H):
  s = input()
  maze.append(s)

def BFS(i,j):
  place = np.zeros((H,W))
  dist = 0
  queue = deque()
  queue.append((i,j,0))
  while queue:
    i,j,d = queue.popleft()
    if not place[i][j]:
      dist = max(dist,d)
      place[i][j] = 1
      for di,dj in [(1,0),(-1,0),(0,1),(0,-1)]:
        if (0 <= i+di and i+di < H and 0 <= j+dj and j+dj < W):
          if maze[i+di][j+dj] == '.' and place[i+di][j+dj] == 0:
            queue.append((i+di,j+dj,d+1))
  return dist

ans = 0
for h in range(H):
  for w in range(W):
    if maze[h][w] == '.':
      ans = max(ans,BFS(h,w))

print(ans)




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

bool is_equal(const vector<int>& a, const vector<int>& b) {
  bool r = true;
  for (int i = 0; i < a.size(); i++) r = r && a[i] == b[i];
  return r;
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n), v(n);
  for (auto& e : p) cin >> e;
  for (auto& e : q) cin >> e;
  iota(v.begin(), v.end(), 1);
  int a, b, i = 0;
  do {
    if (is_equal(v, p)) a = i;
    if (is_equal(v, q)) b = i;
    i++;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String n = in.nextLine();
		List<String> m = new ArrayList<String>();
		String memo="";
		for(int s=0;s<n.length();s++){
			if(n.charAt(s)==' '||n.charAt(s)==','||n.charAt(s)=='.'){
				if(memo.length()!=0&&memo.length()>=3&&memo.length()<=6)m.add(memo);
				memo="";
				continue;
			}
			memo+=n.charAt(s);
		}
		for(int i=0;i<m.size()-1;i++)System.out.print(m.get(i)+" ");
		System.out.println(m.get(m.size()-1));
	}
}

Measured memory_bytes: 17208
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
# from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
import math
# from itertools import product, accumulate, combinations, product
#import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())



def run():
    N, *A = mapread()
    LEFT = [0] * (N+2)
    RIGHT = [0] * (N+2)
    for i, a in enumerate(A, 1):
        LEFT[i] = math.gcd(LEFT[i-1], a)
    for i in range(N-1, -1, -1):
        k = i+1# for RIGHT
        RIGHT[k] = math.gcd(RIGHT[k+1], A[i])
    #print(LEFT)
    #print(RIGHT)
    ans = 0
    for i in range(N):
        k = i + 1# for LEFT and RIGHT
        v = math.gcd(LEFT[k-1], RIGHT[k+1])
        #print(v)
        ans = max(ans, v)

    print(ans)



if __name__ == "__main__":
    #print(math.gcd(0, 10))
    run()


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
const int MC = 200010;
int N;
vector<int> V[MC];
vector<LL> ans[MC];
vector<LL> ans0[MC];
int reset[MC];
LL inv2 = (mod+1) / 2;

void dfs(int q){
	reset[q] = -1;
	for(auto u : V[q]){
		dfs(u);
		if(ans[q].size() < ans[u].size()){
			swap(ans[q],ans[u]);
			swap(ans0[q],ans0[u]);
			swap(reset[q],reset[u]);
		}
		int z = ans[q].size() - ans[u].size();
		while(reset[u] >= 0){
			ans0[u][reset[u]] = (mod+1-ans[u][reset[u]]) % mod;
			--reset[u];
		}
		while(reset[q] >= z){
			ans0[q][reset[q]] = (mod+1-ans[q][reset[q]]) % mod;
			--reset[q];
		}
		repp(i,0,ans[u].size()){
			ans[q][z+i] = (ans0[q][z+i] * ans[u][i] + ans0[u][i] * ans[q][z+i]) % mod;
			(ans0[q][z+i] *= ans0[u][i]) %= mod;
		}
	}
	ans[q].PB(inv2);
	ans0[q].PB(inv2);
	reset[q] = ans[q].size()-2;
}

int main(){
	cin >> N;
	repp(i,1,N+1){
		int p;
		cin >> p;
		V[p].PB(i);
	}
	dfs(0);
	repp(i,1,ans[0].size()) (ans[0][0] += ans[0][i]) %= mod;
	repp(i,0,N+1) (ans[0][0] *= 2) %= mod;
	cout << ans[0][0] << endl;
	return 0;
}


Measured memory_bytes: 43492
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int n;
    string s;
    int aa=0;
    cin >> s;
    n = s.length();

    for(int i=0; i<n; ++i){
        if(i%2==0){
            if(s[i]=='0') ++aa;
        }else{
            if(s[i]=='1') ++aa;
        }
    }
    cout << min(aa,(n-aa)) << endl;

    return 0;
}



Measured memory_bytes: 512
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""
s=ip()
a=s.count('1')
b=s.count('0')
print(min(a,b)*2)


Measured memory_bytes: 46064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    vector<int> d(n) ;
    for (size_t i = 0; i < n; i++)
    {
        /* code */
        cin >> d.at(i) ;
    }
    int64_t ans = 0;
    for (size_t i = 0; i < n-1; i++)
    {
        for (size_t j = i+1; j < n; j++)
        {
            /* code */
            ans += d.at(i)*d.at(j) ;
        }
        
    }
    cout << ans <<endl ;
    
    
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])
 
dp = [0, 1]
for i in range(N):
    if i+1 in A: dp.append(0)
    else: dp.append(dp[i]+dp[i+1])
print(dp[N+1]%1000000007)

Measured memory_bytes: 464392
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<iomanip>
using namespace std;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;


int main(){
	int N;
	cin>>N;
	int A;
	double ans = 0;
	for(int i = 0; i < N; i++){
		cin>>A;
		ans+=1.0/A;
	}
	cout<<setprecision(15)<<1.0/ans<<endl;
	
}

Measured memory_bytes: 256
def main():
    S = list(input())
    T = list(input())

    lenS = len(S); lenT = len(T)
    idx = -1
    for i in range(lenS-lenT+1):
        if S[i] in ['?', T[0]]:
            flag = True
            for j in range(1, lenT):
                if not S[i+j] in ['?', T[j]]:
                    flag = False
                    break
            if flag:
                idx = max(idx, i)
    if idx == -1:
        print('UNRESTORABLE')
        return
    
    s = S[:idx] + T + S[idx+lenT:]
    ans = ''.join(s).replace('?', 'a')
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
char c;
bool flag;

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


int main(void) {
  vll t, x, y;
  ll a, b, c;
  ll time, xn, yn;

  cin >> n;

  FOR(i, 0, n) {
	cin >> a >> b >> c;
	t.push_back(a);
	x.push_back(b);
	y.push_back(c);
  }

  xn = x[0];
  yn = y[0];

  time = t[0] - x[0] - y[0];

  if (time % 2 != 0 || time < 0) {
	cout << "No" << endl;
	return 0;
  }

  time = t[0];

  FOR(i, 1, n) {
	time = (t[i] - time) - (x[i] - xn) - (y[i] - yn);
	if (time % 2 != 0 || time < 0) {
	  cout << "No" << endl;
	  return 0;
	}
	xn = x[i];
	yn = y[i];
	time = t[i];
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    int ans = 0, s = 1;
    FOR(i, 0, n) {
        if (a[i] % 2 == 0) {
            ans += s * pow(3, n - i - 1);
            s *= 2;
        }
        else ans += s * 2 * pow(3, n - i - 1);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import math
def eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i+1 for i in range(1,n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e%p != 0]

_primes = eratosthenes(10**5)
primes = [False] * (10**5+1)

for p in _primes:
    primes[p] = True

like_2017 = [False] * (10**5+1)
for p in _primes:
    if primes[(p+1)//2]:
        like_2017[p] = True

c = 0
C = [0]
for i in range(1,10**5+1):
    if like_2017[i]:
        c += 1
    C.append(c)

q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    print(C[r] - C[l-1])

Measured memory_bytes: 56772
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

vector<vector<pair<int,ll>>> G;

vector<ll> dijkstra(int N,int p){
	vector<ll> dist(N,LINF);
	vector<bool> visited(N,false);
	priority_queue<pair<ll,int>> q;
	dist[p] = 0;
	q.push(make_pair(0,p));
	while(!q.empty()){
		pair<ll,int> f = q.top();
		q.pop();
		int u = f.second;

		if(dist[u] < f.first*(-1)) continue;
		visited[u] = true;

		rep(i,G[u].size()){
			int v = G[u][i].first;
			if(visited[v] == true) continue;

			if(dist[v] > dist[u] + G[u][i].second){
				dist[v] = dist[u] + G[u][i].second;
				q.push(make_pair(dist[v]*(-1),v));
			}
		}
	}
	return dist;
}

int main(){
    int N; cin >> N;
    G.resize(N);
    rep(i,N-1){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        G[a].emplace_back(b,c);
        G[b].emplace_back(a,c);
    }
    int Q,K; cin >> Q >> K;
    K--;
    vector<ll> dist = dijkstra(N,K);
    rep(i,Q){
        int x,y; cin >> x >> y;
        x--; y--;
        cout << dist[x]+dist[y] << "\n";
    }
}
    



Measured memory_bytes: 11120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
using namespace std;

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<long long>a(n + 1), b(n);
	for (int i = 0; i < n+1; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n; i++) {
		if (b[i] >= a[i]) {
			sum += a[i] + min(b[i] - a[i], a[i + 1]);
			a[i + 1] = max(a[i + 1] - (b[i] - a[i]), (long long)0);
		}
		else sum += b[i];
	}
	cout << sum << endl;
}


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

using namespace std;


int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    string S;
    
    cin >> N;
    cin.ignore(1024, '\n');
    getline(cin, S);
    
    int count = 0;
    
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                string::size_type left = S.find(to_string(i));
                string::size_type right = S.rfind(to_string(k));
                if (left == string::npos || right == string::npos || left >= right) {
                    continue;
                }
                string remain = S.substr(left + 1, right - left - 1);
                string::size_type middle = remain.find(to_string(j));
                if (middle != string::npos) {
                    count++;
                    //cout << i << j << k << endl;
                }
            }
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 384
//region trash
#ifndef LOCAL
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define DB(x){if(cond)cerr<<__LINE__<<" "<<#x<<" " <<x<<endl;}
#else
#define DB(x){}
#endif
#define REP(i,b)for(auto i=0;i<(b);++i)
#define FOR(i,a,b)for(auto i=(a);i<=(b);++i)
#define FORD(i,a,b)for(auto i=(a);i>=(b);--i)
#define FORDE(rit,x)for(auto rit=(x).rbegin();rit!=(x).rend();rit++)
#define VV vector
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
template<typename X, typename Y>bool MA(X&a,Y b){if(a<b){a=b;return true;} return false;}
template<typename X, typename Y>bool MI(X&a,Y b){if(a>b){a=b;return true;} return false;}
typedef long long LL,ll;typedef long double LD,ld;
typedef array<int,2>I2,i2;typedef VV<int>VI,vi;
using namespace std;
int cond=0;
//endregion

int mode=0;

struct Solver {
  int R,C,N;
  void solve() {
    cin>>R>>C>>N;
    int SR,SC; cin>>SR>>SC;

    string A,B;cin>>A>>B;

    int R1=1,R2=R,C1=1,C2=C;

    FORD(n,N-1,0) {
      //B[n]
      if (B[n] == 'L') C2=min(C,C2+1);
      if (B[n] == 'R') C1=max(1,C1-1);
      if (B[n] == 'U') R2=min(R,R2+1);
      if (B[n] == 'D') R1=max(1,R1-1);

      //A[n]
      if (A[n] == 'L') C1++;
      if (A[n] == 'R') C2--;
      if (A[n] == 'U') R1++;
      if (A[n] == 'D') R2--;
      if (!(R1<=R2&&C1<=C2)) {
        cout<<"NO\n";
        return;
      }
    }
    DB(R1<<" "<<R2<<" "<<C1<<" "<<C2);
    if (R1 <= SR && SR <= R2 && C1 <= SC && SC <= C2)
      cout<<"YES\n";
    else
      cout<<"NO\n";
  }
};


int main(int argc,char** argv){
  struct Solver2 {
    void gen() {}
    void brute() {}
  };
  random_device rd{};
  uint64_t seed = (uint64_t)rd()
      ^ (uint64_t)std::chrono::steady_clock::now().time_since_epoch().count()
      ^ (uint64_t)__builtin_ia32_rdtsc()
      ^ (uint64_t)make_unique<char>().get();
  srand(seed); mt19937 rng(seed);

  ios::sync_with_stdio(false),cin.tie(nullptr);
  FOR(a,1,argc-1){if(argv[a][0]=='g') { Solver2 solver; solver.gen(); return 0; }}
  FOR(a,1,argc-1){if(argv[a][0]=='q') cond=1U<<30U;}
  cout.setf(ios::fixed),cout.precision(10);
  int t{};if(mode >= 1)cin>>t;else t=1;
  bool isBrute=false;FOR(a,1,argc-1)if(argv[a][0]=='b')isBrute=true;
  FOR(i,1,t){if(cond)cerr<<__LINE__<<" "<<i<<endl;if(mode == 2)cout<<"Case #"<<i<<": ";
    auto solver = make_unique<Solver>();
    auto solver2 = make_unique<Solver2>();
    if (isBrute)
      solver2->brute();
    else
      solver->solve();
  }
  return 0;
}


Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b;
  cin >>a>>b;
  
  cout << a-b+1 << endl;
}



Measured memory_bytes: 256
import sys

#sys.stdin = open("second.txt","r")

def main():
	k, x = map(int, raw_input().split())
	for i in xrange(x - k + 1, x + k):
		print i,
	print ""

raw_input = sys.stdin.readline

if __name__ == '__main__':
	#for j in xrange(int(raw_input())):
	main()

Measured memory_bytes: 2568
import scala.collection.mutable
import scala.io.StdIn._

object Main extends App {
  val _        = readInt
  val countMap = mutable.Map[Int, Int]().withDefaultValue(0)
  readLine.split(" ").map(_.toInt).foreach(i => {
    countMap(i - 1) += 1
    countMap(i) += 1
    countMap(i + 1) += 1
  })
//  println(countMap.maxBy { case (k, v) => v })
  println(countMap.values.max)
}


Measured memory_bytes: 50024
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
long long cnt = 0;
int main() {

	int n;
	cin >> n;
	vi arr(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		arr[a - 1] = i + 1;
	}
	for (int i : arr)
		cout << i << ' ';
}



Measured memory_bytes: 1152
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
tmp = [[0 for i in range(6)] for j in range(n+1)]
absDiff = abs(x[0]-y[0])
tmp[0][3] = tmp[0][0] = absDiff
tmp[0][4] = tmp[0][1] = absDiff ** 2
tmp[0][5] = tmp[0][2] = absDiff ** 3
max = absDiff
for i in range(1, n, 1):
    absDiff = abs(x[i]-y[i])
    tmp[i][0] = absDiff
    tmp[i][1] = absDiff ** 2
    tmp[i][2] = absDiff ** 3
    tmp[i][3] = tmp[i-1][3] + tmp[i][0]
    tmp[i][4] = tmp[i-1][4] + tmp[i][1]
    tmp[i][5] = tmp[i-1][5] + tmp[i][2]
    if absDiff > max:
        max = absDiff
print(tmp[n-1][3])
print(math.sqrt(tmp[n-1][4]))
print(tmp[n-1][5] ** (1/3))
print(max)

Measured memory_bytes: 7940
#入力した文字列から順に文字を取り除いていく
#dreamerやdreamから削ると、削った文字列が本当にdreamerやdreamなのか判断できないため、eraserやeraseから削る
S=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")

#文字列Sが空にの場合OK
if S:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j >= 0) and A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)

Measured memory_bytes: 7996
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  string s,t,t1;
  cin>>s>>t;
  if (s.length()==(t.length()-1))
  {
    t1=t.substr(0,(s.length()));
    int c=0;
    for (int i=0;i<s.length();i++)
    {
      if (s.at(i)==t1.at(i))
        c++;
    }
    if (c==s.length())
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  else
    cout<<"No"<<endl;
  return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mod = 1e9 + 7;

int qp(int x, int n) {
	int ans = 1;
	for (; n; n >>= 1, x = 1LL * x * x % mod)
		if (n & 1) ans = 1LL * ans * x % mod;
	return ans;
}

int main() {
	int n;
	scanf("%d", &n);
	if (n == 1) {
		puts("0");
		return 0;
	}
	int ans = qp(10, n);
	ans = (ans + mod - 2LL * qp(9, n) % mod) % mod;
	ans = (ans + qp(8, n) % mod) % mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
map<ll, ll> factor;
/* function */
void primeFactorization(ll n) {
    ll x = n;
    if (x < 2) {
        factor[x]++;
        return ;
    }
    for (ll i = 2; i*i <= n; i++) {
        while (x%i == 0) {
            factor[i]++;
            x /= i;
        }
    }
    if (x != 1)
        factor[x]++;
    return;
}
int judge(ll x) {
    int ret = 1;
    while (true) {
        if (ret * (ret+1) / 2 > x) {
            return ret - 1;
        }
        ret++;
    }
}
/* main */
int main() {
    ll N;
    cin >> N;
    if (N == 1) {
        cout << 0 << '\n';
        return 0;
    }
    primeFactorization(N);
    int ans = 0;
    for (auto f : factor) {
        //cout << f.first << ' ' << f.second << '\n';
        ans += judge(f.second);
    }
    cout << ans << '\n';

}

Measured memory_bytes: 3640
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
  var input = input.split("\n");
  var sample = 'CODEFESTIVAL2016'.split('');
  var S = input[0].substring(0,16).split('');

  // var arr = tmp.map(function(n){return parseInt(n)});

  var max_iteration = 0;

  for (var i=0, len=sample.length; i<len; i++){
    if(S[i]!==sample[i]){
      max_iteration++;
    }
  }

	//output
	console.log(max_iteration);
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 6904
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = k;
        for(int i = 1;i<n;i++){
            ans *= k-1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#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(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    string S;
    cin >> S;
    int K, N = S.size();
    cin >> K;

    rep(i, N)
    {
        if (S[i] != '1')
        {
            cout << S[i];
            return 0;
        }
        else if (i == K - 1)
        {
            cout << 1;
            return 0;
        }
    }
    cout << 1;
    return 0;
}

Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()

using LL = long long;
int vis[100005];
vector <int> ans;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
	return getchar();
//    if (ib == ie) {
//        ib = ibuf;
//        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
//    }
//    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

using P = pair<int,int> ;
vector<vector<P> > g(100005 + 1);
int b[100005];
#define fi first
#define se second

void dfs(int x)
{
	vis[x]=1;
	for(auto u:g[x])
	{
		if(vis[u.first]) continue;
		dfs(u.first);
		if(b[u.first])
		{
			ans.push_back(u.second);
			b[u.first]^=1;
			b[x]^=1;
		}
	}
}

int main() {
    int n = read();
    int m = read();
    vector<P> bomb;
    for (int i = 0; i < n; ++i) {
        int a = read(), b = read();
        bomb.emplace_back(a, b);
    }
    sort(begin(bomb), end(bomb));
    for(int i=0;i<n;i++)
    {
    	b[i]=bomb[i].second;
	}
	for(int i=n;i>=0;i--)
	{
		b[i]^=(i?b[i-1]:0);
	}
    for (int i = 1; i <= m; ++i) {
        int l = read(), r = read();
        int ll = lower_bound(begin(bomb), end(bomb), P(l, 0)) - begin(bomb);
        int rr = upper_bound(begin(bomb), end(bomb), P(r, 1)) - begin(bomb);
        g[ll].emplace_back(rr, i);
        g[rr].emplace_back(ll, i);
    }
    
	for(int i=0;i<=n;i++)
	{
		if(vis[i]) continue;
		dfs(i);
		if(b[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	sort(all(ans));
	cout<<ans.size()<<endl;
	for(auto x:ans)
	{
		printf("%d ",x);
	}
	cout<<endl;
    return 0;
}


Measured memory_bytes: 14580
using System;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In = Console.ReadLine().Split(' ');
            long n = long.Parse(In[0]);
            long k = long.Parse(In[1]);
            long bef = n % k;
            long af = k - bef;
            if (bef < af)
            {
                Console.WriteLine(bef);
            }
            else
            {
                Console.WriteLine(af);
            }
        }
    }
}

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

int main() {
  int n; cin >> n;
  
  /*
  後で使うlower_boundは、探索している値が見つからないときは、
  その探索範囲の最後のイテレータを返す関数。
  そのため、探索している値が見つからなかったときに備えて、
  配列の最後に非常に大きな値を入れておくことにする。
  */
  vector<int>L(n+1);
  rep(i,n) cin >> L[i];
  L[n] = INF; //配列の最後に大きな値を入れておく（上述）。
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i=0; i<=n-3; i++){
    for (int j=i+1; j<=n-2; j++){
      int border = L[i]+L[j];
      auto itr = lower_bound(L.begin(), L.end(), border);

      /*
      lower_boundの返り値が配列の最後（itr == L.end(）)のとき、
      このiとjの値のときは作れる三角形は存在しない。
      そのため、itr != L.end(）の場合のみ答えとなる個数を加算していく。
      */
      if (itr != L.end()){
        int index = itr - L.begin();
        ans += index-1-j;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3576
from collections import deque

V, E, r = map(int, input().split())

INF = 2 << 21
G = [[] for i in range(V)]
dist = [INF for j in range(V)]


def bellman_ford(s):
    p, q1 = [-1 for i in range(V)], deque()
    dist[s], cnt = 0, 0
    q1.append(s)

    while True:
        if cnt >= 2 * V:
            return False

        if len(q1) == 0:
            return True

        q2 = deque()
        for i in q1:
            for j in G[i]:
                if dist[i] + j[1] < dist[j[0]]:
                    dist[j[0]], p[j[0]] = dist[i] + j[1], i
                    q2.append(j[0])

        q1 = q2
        cnt += 1


def main():
    for i in range(E):
        s, t, d = map(int, input().split())
        G[s].append((t, d))

    check = bellman_ford(r)

    if check:
        for i in range(V):
            if dist[i] == INF:
                print("INF")
            else:
                print(dist[i])
    else:
        print("NEGATIVE CYCLE")


if __name__ == '__main__':
    main()



Measured memory_bytes: 6520