akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = II()
    s = input()
    print(s if a >= 3200 else "red")
    return

#B
def B():
    II()
    a = LI()
    ans = 0
    for ai in a:
        ans += 1 / ai
    print(1/ans)
    return

#C
def C():
    n = II()
    v = LI()
    q = []
    for vi in v:
        heappush(q, vi)
    while 1:
        a = heappop(q)
        if q:
            b = heappop(q)
            heappush(q, (a + b) / 2)
        else:
            print(a)
            return

#D
def D():
    n, q = LI()
    tree = [[] for i in range(n)]
    for _ in range(n - 1):
        a, b = LI_()
        tree[a].append(b)
        tree[b].append(a)
    ans = [0] * n
    c = defaultdict(int)
    def dfs(now):
        for nex in tree[now]:
            if c[nex]:
                continue
            c[nex] += 1
            ans[nex] += ans[now]
            dfs(nex)
    for _ in range(q):
        p, x = LI_()
        x += 1
        ans[p] += x
    c[0] = 1
    dfs(0)
    print(*ans)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    B()


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

int n;
long double ans = 0, tmp;

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> tmp;
		ans += 1/tmp;
	}

	printf("%.7Lf\n", 1/ans);
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	int a, b; cin >> a >> b;
	cout << 6-a-b << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

const int mxN = 2e5;
int n, m;
int k, a[mxN + 1], b[mxN + 1];

void solve() {
	cin >> n >> m >> k;
	rep(i, 0, n - 1) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	rep(i, 0, m - 1) {
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}
	int ans = 0;
	for (int i = 0, j = m; i <= n; ++i) {
		if (a[i] > k)
			break;
		while (a[i] + b[j] > k)
			--j;
		ans = max(i + j, ans);
	}
	cout << ans;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 6764
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll a[200010];
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		a[t]++;
	}
	sortdown(a,n+1);
	ll ans=0;
	rep(i,0,k)ans+=a[i];
	printf("%lld\n",n-ans);
	
}

Measured memory_bytes: 3324
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var N int
	fmt.Scan(&N)
	sc.Split(bufio.ScanWords)
	count := 0
	for i := 0; i < N; i++ {
		tmp := nextInt()
		if i%2 == 0 {
			if tmp%2 == 1 {
				count++
			}
		}
	}

	fmt.Print(count)

}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 1840
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const ll mod = 1e9+7;
ll dp[1010];

int main() {
    ll n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    vector<ll> sum(n+1);
    rep(i,n) sum[i+1] = sum[i]+a[i];

    typedef pair<ll, ll> P;
    auto func = [&](int k) -> P {
        ll num = 0, s = 0;
        rep(i,n) {
            int j = lower_bound(a.begin(), a.end(), k-a[i]) - a.begin();
            num += n-j;
            s += a[i]*(n-j);
            s += sum[n] - sum[j];
        }
        return P(num, s);
    };

    // ax+ayの最小値を固定したとき
    // 握手回数がm回以上となる最大のax+ayを求める
    int left = 0, right = 200010;
    while (left+1<right) {
        int mid = (left+right)/2;
        if (func(mid).first < m) right = mid;
        else left = mid;
    }

    // m回以上握手している場合があるので握手合計をmにする
    P p = func(left);
    ll ans = p.second - (p.first-m)*left;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<std::pair<int, int>> edge(n - 1);
	for (auto& e : edge) std::cin >> e.first >> e.second;
	std::vector<std::vector<int>> nodes(n);
	int max_color = 0;
	for (auto i = 0; i < edge.size(); ++i) {
		nodes[--edge[i].first].push_back(i);
		nodes[--edge[i].second].push_back(i);
		max_color = std::max(max_color, (int)nodes[edge[i].first].size());
		max_color = std::max(max_color, (int)nodes[edge[i].second].size());
	}
	std::vector<int> color(n - 1, - 1);
	std::queue<int> queue; queue.push(0);
	std::unordered_set<int> color_set;
	while (!queue.empty()) {
		auto top = queue.front(); queue.pop();
		color_set.clear();
		int c = 1;
		for (const auto e : nodes[top]) {
			if (color[e] != -1) {
				color_set.insert(color[e]);
			}
		}
		for (const auto e : nodes[top]) if (color[e] == -1) {
			while (color_set.find(c) != color_set.end()) {
				++c;
			}
			color[e] = c++;
			if (edge[e].first != top) {
				queue.push(edge[e].first);
			}
			else {
				queue.push(edge[e].second);
			}
		}
	}
	std::cout << max_color << '\n';
	for (auto c : color) std::cout << c << '\n';
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int x=0, y=0;
    rep(i, n) {
        cin >> a[i];
        if (a[i]%4 == 0) x++;
        else if (a[i]%2 == 0) y++;
    }

    if (y > 0) n += -y + 1;
    // cout << n << ' ' << x << ' ' << y << endl;

    if (n/2 <= x) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

string s;

int main() {
  cin >> s;
  map<string, int> m;
  m["SUN"] = 7;
  m["MON"] = 6;
  m["TUE"] = 5;
  m["WED"] = 4;
  m["THU"] = 3;
  m["FRI"] = 2;
  m["SAT"] = 1;
  cout << m[s] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);

    ll ans = 0;
    if(n % 2 == 0){
        int div = n / 2;
        for(int i = 0; i < n; i++){
            if(i < div-1){
                ans -= (a[i]*2);
            }else if(i == div-1){
                ans -= a[i];
            }else if(i == div){
                ans += a[i];
            }else{
                ans += (a[i]*2);
            }
        }
        cout << ans;
    }else{
        ll tmp1 = 0,tmp2 = 0;
        int div = n / 2;
        for(int i = 0; i < n; i++){
            if(i < div){
                tmp1 -= (a[i]*2);
            }else if(i == div || i == div+1){
                tmp1 += a[i];
            }else{
                tmp1 += (a[i]*2);
            }
        }
        for(int i = 0; i < n; i++){
            if(i < div-1){
                tmp2 -= (a[i]*2);
            }else if(i == div-1 || i == div){
                tmp2 -= a[i];
            }else{
                tmp2 += (a[i]*2);
            }
        }
        if(tmp1 < tmp2){
            cout << tmp2;
        }else{
            cout << tmp1;
        }
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <set>
#include <string>
#include <math.h>
#include <map>
#include <climits>
#include <iomanip>


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

#define ll long long

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

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

	A();


}

void A() {
	int n;
	cin >> n;

	double cir = n * 2 * 3.14159265358979323846;
	cout << setprecision(8) << cir << endl;
}
 
void B() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void C() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void D() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void E() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void F() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}



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


#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }



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


// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+2, vector<int>(26, n+1));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'a'] = i;
    }
    return res;
}

string solve(const string &S) {
    int n = (int)S.size();

    // 前処理配列
    auto next = calcNext(S);

    // DP
    vector<int> dp(n+1, 1<<29); // DP テーブル
    vector<char> recon(n+1, 'a'); // 復元用テーブル
    dp[n] = 1;
    for (int i = n - 1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) {
            // 次の文字がないとき
            if (next[i][j] == n+1) {
                if (dp[i] > 1) {
                    dp[i] = 1;
                    recon[i] = 'a'+j;
                }
            }
            // 次の文字があるとき
            else if (chmin(dp[i], dp[next[i][j] + 1] + 1)) {
                recon[i] = 'a'+j;
            }
        }
    }

    // 復元
    string res = "";
    int index = 0;
    while (index <= n) {
        res += recon[index];
        index = next[index][recon[index]-'a'] + 1;
    }
    return res;
}

int main() {
    string S;
    while (cin >> S) 
    cout << solve(S) << endl;
}



Measured memory_bytes: 28036
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) throws IOException {
        int num = receiveInt();
        int[] arr1 = receiveIntArray(Delimiter.SPACE);
        int[] arr2 = receiveIntArray(Delimiter.SPACE);

        boolean swapFlag = false;
        int ans = 0;
        for (int i = 0; i < num; i++) {
            if (arr1[i] > arr2[i]) {
                swapFlag = true;
                ans += (arr1[i] - arr2[i]) * factorial(num - i - 1);
            } else if (arr1[i] < arr2[i]) {
                if(!swapFlag) {
                    int[] tmp = arr1;
                    arr1 = arr2;
                    arr2 = tmp;
                }
                swapFlag = true;
                ans += (arr1[i] - arr2[i]) * factorial(num - i - 1);
            }

            for (int j = i + 1; j < num; j++) {
                if (arr1[j] > arr1[i])
                    arr1[j]--;
                if (arr2[j] > arr2[i])
                    arr2[j]--;
            }
        }

        println(ans);
        flush();
    }

    // math
    public static int combination(int n, int k) {
        int ans = 1;
        if (n == 0 || k == 0)
            return 1;
        for (int i = 0; i < k; i++) {
            ans *= n - i;
        }
        ans /= factorial(k);
        return ans;
    }

    public static int factorial(int n) {
        int ans = 1;
        for (int i = 1; i <= n; i++)
            ans *= i;
        return ans;
    }

    // 入出力関連
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);

    enum Delimiter {
        NONE(""), SPACE(" "), DOT("\\."), COMMA(",");

        private String regex;

        private Delimiter(String regex) {
            this.regex = regex;
        }

        public String getRegex() {
            return regex;
        }
    }

    static String receive() throws IOException {
        return br.readLine();
    }

    static int receiveInt() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    static char receiveChar() throws IOException {
        return br.readLine().charAt(0);
    }

    static char[] receiveCharArray() throws IOException {
        return br.readLine().toCharArray();
    }

    static int[] receiveIntArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).mapToInt(Integer::parseInt).toArray();
    }

    static String[] receiveStringArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).toArray(String[]::new);
    }

    static void print(Object obj) {
        pw.print(obj);
    }

    static void println(Object obj) {
        pw.println(obj);
    }

    static void flush() {
        pw.flush();
    }
}

Measured memory_bytes: 26708
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <limits>
#include <string>


template<class... Ts> using tuple_t = std::tuple<Ts...>;
template<class T, class U> using map_t = std::map<T, U>;
template<class T, class U> using pair_t = std::pair<T, U>;
template<class T> using vector_t = std::vector<T>;
template<class T> using set_t = std::set<T>;

uint64_t digit(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		++i;
		num /= base;
	}
	return i;
}

uint64_t digit_sum(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		i += num % base;
		num /= base;
	}
	return i;
}

int min(vector_t<int> nums)
{
	int min_ = std::numeric_limits<int>::max();
	for(auto& i :nums)
		if(min_ > i)
			min_ = i;
	return min_;
}
int max(vector_t<int> nums)
{
	int max_ = std::numeric_limits<int>::min();
	for(auto& i :nums)
		if(max_ < i)
			max_ = i;
	return max_;
}
int first_min(vector_t<int> nums, int start = 0)
{
	int min_ = min(nums);
	for(int i = start; i < nums.size(); ++i)
		if(nums[i] == min_)
			return i;
	return 0;
}

int main()
{
	std::string s;
	int w;
	std::string result="";
	std::cin >>s;
	std::cin>>w;
	for(int i=0;i<s.size();i+=w)
		result+=s[i];
	std::cout<<result<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  char c[20];
  rep(i,12)cin >> c[i];
  rep(i,4)printf("%c",c[i]);
  printf(" ");
  FOR(i,4,12)printf("%c",c[i]);
  printf("\n");
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 300100;
const int MOD = (int) 1e9 + 7;

int n, a[N], f[N], d[N];

int main() {

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		f[a[i]] = 0;
	}

	d[0] = 1;

	for (int i = 1; i <= n; i++) {
		d[i] = d[i - 1];
		if (i == 0 || a[i] != a[i - 1]) {
			d[i] += f[a[i]];
			d[i] %= MOD;
			f[a[i]] += d[i - 1];
			f[a[i]] %= MOD;
		}
	}

	printf("%d\n", d[n]);

	return 0;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<vector<pair<int,int>>> k(n,vector<pair<int,int>>(1,make_pair(-1,-1)));
  rep(i,n-1){
    int c,d,e;
    cin >> c >> d >> e;
    c--;
    d--;
    k[c].push_back(make_pair(d,e%2));
    k[d].push_back(make_pair(c,e%2));
  }  
  int ans[n];
  rep(i,n)ans[i]=-1;
  queue<pair<int,int>> q;
  q.push(make_pair(0,0));
  while(q.size()!=0){
    pair<int,int> p=q.front();
    q.pop();
    int a=p.first,b=p.second;
    ans[a]=b;
    for(pair<int,int> z:k[a]){
      int aa=z.first,bb=z.second;
      if(aa==-1)continue;
      if(ans[aa]!=-1)continue;
      q.push(make_pair(aa,(b+bb)%2));
    }
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 8320
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main() {
	lint n; cin >> n;
	lint cnta = 0;
	lint cntb = 0;
	for (int i = 0; i < n; i++) {
		lint x; cin >> x;
		if (x % 4 == 0)
			cnta++;
		else
			if (x % 2 == 0)
				cntb++;
	}
	lint x = n - cnta - cntb;
	if (cntb == 0) {
		if (cnta + 1 >= x)
			puts("Yes");
		else
			puts("No");
	}
	else {
		if (cnta >= x)
			puts("Yes");
		else
			puts("No");
	}

	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

ll x[200010], sa[200010];

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

int main() {
	int n;
	cin >> n >> x[0];
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	if (n == 1) {
		cout << abs(x[0] - x[1]) << endl;
		return 0;
	}
	sort(x, x + n + 1);
	for (int i = n - 1; i >= 0; i--) {
		sa[i] = x[i + 1] - x[i];
	}
	ll mi = gcd(sa[0], sa[1]);
	for (int i = 2; i < n; i++) {
		mi = gcd(mi, sa[i]);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans=1;
    cin>>n>>k;
    rep(i,n){
        ans*=k;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3172
#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++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

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

    vector<pair<string,int>>rist(n);
    rep(i,n){
        string s;
        int t;
        cin>>s>>t;
        rist[i]=make_pair(s,t);
    }

    string x;
    cin>>x;

    int ans=0;
    bool jdg=false;

    rep(i,n){
        if(jdg){
            ans+=rist[i].second;
        }
        if(rist[i].first==x){
            jdg=true;
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
fun main(args:Array<String>){
  var (n,m) = readLine()!!.split(" ").map(String::toInt)
  var s = readLine()!!.toCharArray()
  when(s[m-1]){
    'A' -> s[m-1] = 'a'
    'B' -> s[m-1] = 'b'
    'C' -> s[m-1] = 'c'
  }
  for(i in 0..n-1){
    print(s[i])
  }
  println()
}

Measured memory_bytes: 37752
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e9;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ll a,b;
    cin >> a >> b;
    ll ans = 0;
    if(a>b) swap(a,b);

    if((a+b)%2==0){
        cout << (a+b)/2;
    }else{
        cout << "IMPOSSIBLE";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int mzd = 0;
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String A = sc.nextLine();
		String B = sc.nextLine();
		String C = sc.nextLine();
		
		int NI = Integer.parseInt(N);
		String[] AL = A.split(" ");
		int[] AI = new int[NI];
		for(int i=0; i<NI; i++) {
			AI[i] = Integer.parseInt(AL[i]);
		}
		String[] BL = B.split(" ");
		int[] BI = new int[NI];
		for(int i=0; i<NI; i++) {
			BI[i] = Integer.parseInt(BL[i]);
		}
		String[] CL = C.split(" ");
		int[] CI = new int[NI-1];
		for(int i=0; i<NI-1; i++) {
			CI[i] = Integer.parseInt(CL[i]);
		}
		
		int temp = 0;
		for(int i=0; i < NI; i++) {
			int crnt = AI[i];
			mzd += BI[crnt-1];
			
			if(temp == 0) {
				temp = crnt;
			}else {
				if(crnt == temp+1) {
					mzd += CI[temp-1];
				}
				temp = crnt;
			}
		}
		System.out.println(mzd);
		sc.close();
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

vector<vector<pair<int, int>>> al(100000);
vector<int> dist(100000, inf * -1);
vector<bool> used(100000, false);

bool bfs(int i, int d) {
	if (used[i]) {
		return d == dist[i];
	}

	used[i] = true;
	dist[i] = d;
	rep(j, al[i].size()) {
		if (!bfs(al[i][j].first, d + al[i][j].second)) return false;
	}
	return true;
}

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

	int n, m;
	cin >> n >> m;

	rep(i, m) {
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		al[l].push_back({ r, d });
		al[r].push_back({ l, -1 * d });
	}

	rep(i, n) {
		if (!used[i]) {
			if (!bfs(i, 0)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 11136
/*author:revolIA*/
/*明日を変えるなら今日変えなきゃ*/
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(1<=a&&a<=9&&1<=b&&b<=9)printf("%d\n",a*b);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  switch (N%10)
  {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout<<"hon"<<endl;
    break;
  case 3:
    cout<<"bon"<<endl;
    break;
  default:
    cout<<"pon"<<endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int N;
long long int Y;

int main(void) {

	cin >> N >> Y;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			if (10000 * i + 5000 * j > Y) { continue; }
			int k = (Y - 10000 * i - 5000 * j)/1000;
			if (i + j + k == N) { cout << i << " " << j << " " << k << endl; return 0; }
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

// common
#define X real()
#define Y imag()

using Vector2 = complex<double>;
using Line = pair<Vector2, Vector2>;
using Segment = pair<Vector2, Vector2>;
const double EPS = 1e-10;
const double PI = 3.14159265359;

bool equals(double a, double b){
    if(abs(a - b) < EPS){
        return true;
    }
    else{
        return false;
    }
}

// struct

struct Circle{
    Vector2 c;
    double r;
    Circle(Vector2 c, double r){
        this->c = c;
        this->r = r;
    }
};

// Vector2
double dot(Vector2 a, Vector2 b){
    return (a.X * b.X + a.Y * b.Y);
}

double cross(Vector2 a, Vector2 b){
    return (a.X * b.Y - a.Y * b.X);
}

int ccw(Vector2 p1, Vector2 p2, Vector2 p3){
    Vector2 a = p2 - p1;
    Vector2 b = p3 - p1;
    double dotValue = dot(a, b);
    double crossValue = cross(a, b);
    if(crossValue > EPS) return 1;  // anticlockwise
    if(crossValue < -EPS) return -1;    // clockwise
    if(dotValue < -EPS) return 2;   // p2-p1-p3
    if(norm(a) < norm(b)) return -2;    // p1-p2-p3
    return 0;   // p1-p3-p2
}

bool intersect(Segment s1, Segment s2){
    if(ccw(s1.first, s1.second, s2.first) * ccw(s1.first, s1.second, s2.second) > 0){
        return false;
    }
    if(ccw(s2.first, s2.second, s1.first) * ccw(s2.first, s2.second, s1.second) > 0){
        return false;
    }
    return true;
}

int main(){

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Segment s1(Vector2(x0, y0), Vector2(x1, y1));
        Segment s2(Vector2(x2, y2), Vector2(x3, y3));
        bool ans = intersect(s1, s2);
        if(ans){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3120
a, b, c, d = map(int, input().split())
ans="No"
ab=a-b
if ab<0:
    ab=-ab
bc=b-c
if bc<0:
    bc=-bc
ac=a-c
if ac<0:
    ac=-ac
if (ab<=d and bc<=d)or (ac<=d):
    ans="Yes"
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		String num = Integer.toString(a);

		if(num.charAt(0) == '7' || num.charAt(1) == '7' || num.charAt(2) == '7') {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}

Measured memory_bytes: 35792
import java.util.Scanner;

public class Main {

	 public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String Nb1 = scan.next();
		int Nb2 = Integer.valueOf(Nb1);
		int S=0;
		String result="";
		int Nb3=Nb2;
		for(int i=0;i<Nb1.length();i++) {
			S=S+Nb2%10;
			Nb2=Nb2/10;
		}
		int resultnb=Nb3%S;
		if(resultnb==0) {
			result="Yes";
		}else {
			result="No";
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>  
using namespace std;
typedef long long int64;

int main(){
  int Q;
  cin >> Q;
  while(Q--){
    int c, a, n;
    cin >> c >> a >> n;

    int hoge = min(c, min(a, n));
    c -= hoge, a -= hoge, n -= hoge;
    int hogehoge = min(c / 2, a);
    c -= hogehoge * 2, a -= hogehoge;
    int hogehogehoge = c / 3;
    c -= c / 3;

    cout << hoge + hogehoge + hogehogehoge << endl;
  }
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int h,w;
char map[100][100];


typedef struct{
	int x;
	int y;
}queue_t;

int max(int x,int y){return x>y?x:y;}
int search(int start_x,int start_y,int end_x,int end_y){
    int dist[100][100]={{}};
	int now_x=start_x,now_y=start_y;
	int flg=0;
	int ret;

	queue_t queue[200000];
	int front=0,back=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			dist[i][j]=-1;
		}
	}
	queue[back].x=start_x;
	queue[back++].y=start_y;
	dist[start_y][start_x]=0;
	while(front!=back){
		flg=0;
		for(int i=0;i<4;i++){
			now_x=queue[front].x+dx[i];
			now_y=queue[front].y+dy[i];
			if(now_x<0||w<=now_x||now_y<0||h<=now_y)continue;
			if(dist[now_y][now_x]!=-1||map[now_y][now_x]=='#')continue;
			queue[back].x=now_x;
			queue[back++].y=now_y;
			flg=1;
			dist[now_y][now_x]=dist[queue[front].y][queue[front].x]+1;
		}
		front++;
		if(!flg){
			//return -1;
		}
		if(dist[end_y][end_x]!=-1){
			//printf("==>%d\n",dist[end_y][end_x]);
			ret=dist[end_y][end_x];
			return ret;
		}
	}
}

int main(){
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",map[i]);
    
    int cnt;
	int dist[200][200];
	int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    if(i==ii&&j==jj)continue;
					if(map[i][j]=='#'||map[ii][jj]=='#')continue;
					//printf("start x=%d y=%d end x=%d y=%d\n",j,i,jj,ii);
					cnt=search(j,i,jj,ii);
					//printf("=>%d\n",cnt);
					if(cnt>ans)ans=cnt;
                }	
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
def main():
    from collections import Counter

    n, k, *a = map(int, open(0).read().split())
    c = Counter(a)
    v = len(c)
    l = list(c.values())
    m = sorted(l)
    ans = sum(m[:v - k])
    print(ans)


if __name__ == '__main__':
    main()


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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    vector<long long int> left(n), right(n), total(n);
    left[0] = a[0];
    right[n-1] = a[n-1];
    for(int i=1; i<n; i++){
        left[i] = gcd(left[i-1],a[i]);
    }
    for(int i=n-2; i>=0; i--){
        right[i] = gcd(a[i], right[i+1]);
    }
    total[0] = right[1];
    total[n-1] = left[n-2];
    for(int i=1; i<n-1; i++){
        total[i] = gcd(left[i-1],right[i+1]);
    }
    sort(total.begin(),total.end());
    cout << total[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3328
import math 

n = int(input())
a=0
b=0
root_n  = math.sqrt(n)
#繰り上げ
root_n = math.ceil(root_n)
yakusuu =[]
for i in range(1,root_n+1):
    if(n%i == 0):
        yakusuu.append(i)
a = max(yakusuu)
b = n / a
print(int(a+b-2))


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

const int MAX = 30000;
const int zero = MAX/2;

int h, w;
int A[80][80];
int B[80][80];
bool dp[81][81][MAX];

signed main(){
  
  cin>>h>>w;
  
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) cin>>A[i][j];

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) cin>>B[i][j];
  
  dp[0][0][zero] = true;
  
  for(int i=0;i<h;i++){
    
    for(int j=0;j<w;j++){
      
      for(int k=0;k<MAX;k++){
	
	if( !dp[i][j][k] ) continue;
	
	for(int l=0;l<2;l++){
	
	  int add;
	  
	  if( l == 0 ) add = A[i][j] - B[i][j];
	  else add = B[i][j] - A[i][j];
	  
	  int nk = k + add;
	  
	  if( nk < 0 || MAX <= nk ) continue;
	  
	  dp[i+1][j][nk] = dp[i][j+1][nk] = true;
	  
	}
	
      }
      
    }
    
  }
  
  int ans = 80;
  
  for(int i=0;i<MAX;i++){
    
    if( dp[h-1][w][i] || dp[h][w-1][i] ) ans = min( ans, abs( i - zero ) );
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


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

long n,a,b;
bool judge(vector<long> x,long t){
  long num = 0;
  for(int i = 0;i < x.size();i++){
    x.at(i) -= t*b;
    if(x.at(i) > 0 && x.at(i) % (a-b) == 0){
      num += x.at(i) / (a-b);
    }
    else if(x.at(i) > 0 && x.at(i) % (a-b) != 0){
      num += x.at(i) / (a-b) + 1;
    }
  }
  //cout << num << endl;
  if(num > t){
    return false;
  }
  else{
    return true;
  }
}
int main(){
  cin >> n >> a >> b;
  vector<long> h(n);
  for(int i = 0;i < n;i++){
    cin >> h.at(i);
  }
  long left = -1,right = 1000000007,mid;
  while(right - left  > 1){
    mid = (right + left) / 2;
    if(judge(h,mid) == true){
      right = mid;
      //cout << 'a' << endl;
    }
    else{
      left = mid;
      //cout << 'b' << endl;
    }
  }
  cout << right << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
  ll N;  cin >> N;
  vector<ll> P(N);  rep(i, N) cin >> P[i];

  ll M = INF;
  ll cnt = 0;
  
  rep(i, N) {
    if (P[i] <= M) {
      cnt++;
    }
    M = min(P[i], M);
  }

  print(cnt);

  return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n,m,c, a; cin >> n >> m >> c;
    vi b(m); rep(i,m) cin >> b[i];

    i32 ans = 0;
    rep(_, n) {
        i64 tmp = c;
        rep(i,m) {
            cin >> a;
            tmp += a * b[i];
        }
        if(tmp > 0) ++ans;
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,b,a)     for(int i=b;i>=a;i--)

int n,arr[22],cnt=1,maxi;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n;
    rep(i,1,n)
        cin>>arr[i];
    maxi=arr[1];
    rep(i,2,n)
    {
        if(arr[i]>=maxi)
            cnt++,maxi=arr[i];
    }
    cout<<cnt;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;
  ll AB=0,A_B=0,ABALL=0;
  
  if(min(X,Y)==X){
    AB=C*2*X+(Y-X)*B;
  }else{
    AB=C*2*Y+(X-Y)*A;
  }
  A_B=A*X+B*Y;
  ABALL=max(X,Y)*2*C;
  cout<<min(AB,min(A_B,ABALL));
    
  return 0;
}


Measured memory_bytes: 256