akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 45

enum Type{
	UNDEFINED,
	TRUE,
	FALSE,
};

struct Info{
	Info(int arg_main_value,int arg_sub_value){
		main_value = arg_main_value;
		sub_value = arg_sub_value;
	}
	bool operator<(const struct Info &arg) const{

		if(main_value != arg.main_value){

			return main_value < arg.main_value;
		}else{

			return sub_value < arg.sub_value;
		}
	}

	int main_value,sub_value;
};

int N,M;
int table[1005][SIZE];
vector<int> G[SIZE];
vector<Info> info;
int ans;
Type type[SIZE];

void recursive(int node_id,int count){

	if(count+(M-node_id+1) <= ans)return;

	if(node_id == M){

		ans = max(ans,count);

		return;
	}

	if(type[node_id] != UNDEFINED){ //決定済

		recursive(node_id+1,count);
		return;
	}

	Type pre[SIZE];
	for(int i = 0; i < M; i++){
		pre[i] = type[i];
	}

	type[node_id] = FALSE;
	recursive(node_id+1,count);

	for(int i = 0; i < M; i++){

		type[i] = pre[i];
	}

	type[node_id] = TRUE;
	for(int i = 0; i < G[node_id].size(); i++){

		type[G[node_id][i]] = FALSE;
	}
	recursive(node_id+1,count+1);
}

void func(){

	info.clear();

	for(int i = 0; i < SIZE; i++){
		G[i].clear();
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < M; k++){
			scanf("%d",&table[i][k]);
		}
	}

	//同時に昇順にできないペアを探す
	for(int i = 0; i < M-1; i++){
		for(int k = i+1; k < M; k++){

			info.clear();

			for(int a = 0; a < N; a++){

				info.push_back(Info(table[a][i],table[a][k]));
			}

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

			bool FLG = true;

			for(int a = 0; a < N-1; a++){
				for(int b = a+1; b < N; b++){
					if(info[a].main_value < info[b].main_value && info[a].sub_value > info[b].sub_value){
						FLG = false;
						break;
					}
				}
				if(!FLG)break;
			}

			if(!FLG){

				G[i].push_back(k);
				G[k].push_back(i);
			}
		}
	}

	ans = 1;
	int first_count = 0;

	for(int i = 0; i < M; i++){

		if(G[i].size() > 0){
			type[i] = UNDEFINED;
		}else{
			type[i] = TRUE; //無条件採用
			first_count++;
		}
	}

	recursive(0,first_count);

	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3440
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()

    // 約数のList
    fun divisor(value: Long): List<Long> {
        val max = Math.sqrt(value.toDouble()).toLong()
        return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
    }

    divisor(n).map {
        n / it + it - 2
    }.min().let(::println)
}




Measured memory_bytes: 44472
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

int n, m, l, k, a, h;
bool pl[110];
int d[110][110];

const int INF = 1e7;

void init(int n){
    rep(i, 0, n){
        rep(j, 0, n){
            d[i][j] = INF;
            if(i == j) d[i][j] = 0;
        }
    }
}
void warshall_floyd(){
    rep(k, 0, n){
        rep(i, 0, n){
            rep(j, 0, n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

signed main(){
    while(1){
        cin >> n >> m >> l >> k >> a >> h;
        if(n + m + l + k + a + h == 0) break;
        rep(i, 0, n) pl[i] = false; 
        rep(i, 0, l){
            int tmp; cin >> tmp;
            pl[tmp] = true;
        }
        init(n);
        rep(i, 0, k){
            int s, t, dist;
            cin >> s >> t >> dist;
            d[s][t] = dist;
            d[t][s] = dist;
        }
        warshall_floyd();
        int e[110][110];
        rep(i, 0, n) rep(j, 0, n) e[i][j] = d[i][j];
        init(n);
        rep(i, 0, n){
            rep(j, 0, n){
                if(pl[i] && pl[j] && e[i][j] <= m){
                    d[i][j] = e[i][j];
                    d[j][i] = e[i][j];
                }
            }
        }
        warshall_floyd();
        int ans = INF;
        if(e[a][h] <= m) ans = e[a][h];        
        rep(i, 0, n){
            rep(j, 0, n){
                if(pl[i] == false || pl[j] == false) continue;
                if(d[i][j] == INF) continue;
                if(e[a][i] > m || e[j][h] > m) continue;
                int tmp = e[a][i] + d[i][j] + e[j][h];
                if(tmp >= m) ans = min(ans, 2 * tmp - m);
                else ans = min(ans, tmp);
            }
        }
        // rep(i, 0, n){
        //     rep(j, 0, n){
        //         cout << e[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;
        // rep(i, 0, n){
        //     rep(j, 0, n){
        //         cout << d[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;
        // ans = max(0, 2 * d[a][h] - m));
        // cout << ans << endl;
        if(ans == INF) cout << "Help!" << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 3060
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	std::vector<int> ac(n+1,0);
	std::map<std::string,int> map;
	rep(i,n) {
		std::string s;
		int t;
		std::cin >> s >> t;
		map[s]=i;
		a[i]=t;
	}
	std::string x;
	std::cin >> x;
	rep(i,n) ac[i+1]=ac[i]+a[i];
	print(ac[n]-ac[map[x]+1]);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[1000000],key,i;
int Partition(int *,int,int);

int Partition(int *A,int p,int r){ 
  int j,x,a;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
       
      a = A[i];
      A[i] = A[j];
      A[j] = a;
    }
  }
  a = A[r];
  A[r] = A[i+1];
  A[i+1] = a;
   
   
  return i+1;
   
}
int main(void){
  int n;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
     
  }
   
  key = Partition(A,0,n);
   
   
  for(i = 1; i < key; i++){
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[key]);
  for(i = key+1;i<=n;i++){
    if(i == n){
      printf("%d\n",A[n]);
    }else{
      printf("%d ",A[i]);
    }
  }
   
  return 0;
}

Measured memory_bytes: 992
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), max = Integer.MIN_VALUE, sum = 0;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();
            sum += j;
            max = Math.max(j, max);
        }
        sum -= max;
        if (max < sum) System.out.println("Yes");
        else System.out.println("No");

    }
}

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

int main() {
    int n;
    cin >> n;
    map<ll, int, greater<ll>> m;
    rep(i, n) {
        ll a;
        cin >> a;
        m[a]++;
    }

    int cnt = 0;
    ll ans = 0;
    for (auto e : m) {
        if (e.second >= 4 && cnt == 0) {
            ans = e.first * e.first;
            cnt += 2;
            break;
        } else if (e.second >= 2) {
            if (cnt == 0)
                ans = e.first, cnt++;
            else if (cnt == 1) {
                ans *= e.first, cnt++;
                break;
            }
        }
    }

    if (cnt == 1) ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9704
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int n, a[20], x[20][20], y[20][20];

int contr(int p){
    bool h[15];
    for(int i = 0; i < n; i++){
        //ある場合において正直者か否か
        h[i] = p & 1;
        p >>= 1;
    }

    for(int i = 0; i < n; i++){
        if(h[i] == 0) continue;

        //iが正直者だった場合
        for(int j = 0; j < a[i]; j++){
            //矛盾
            if(y[i][j] == 0 && h[x[i][j]-1] == 1) return 0;
            if(y[i][j] == 1 && h[x[i][j]-1] == 0) return 0;
        }
    }

    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += h[i];
    }

    return sum;
}   

int main(){
    int ans = 0;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        for(int j = 0; j < a[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }

    for(int bits = 1; bits < (1<<n); bits++){
        ans = max(ans, contr(bits));
    }

    cout << ans << endl;
    return 0;
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

int mark[N],freq[N];

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,x;
        cin>>n;
        int a[n];
        bool one = false;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            a[i] = x;
            freq[x]++;
            if(x == 1)one = true;
            if(one)continue;
            for(int j=2*x;j<N;j+=x)mark[j]++;
        }
        int ans = 0;
        if(one) ans = (freq[1]==1);
        else for(int i=0;i<n;i++)ans+=(!mark[a[i]] && freq[a[i]]==1);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 20720
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int result = 0;
    for (int i = 1; i <= N; i++) {
      int tmp = digitSum(i);
      if (tmp >= A && tmp <= B) {
        result += i;
      }
    }
    System.out.println(result);
  }

  public static int digitSum(int number) {
    int sum = 0;
    while (number > 0) {
      sum += (number % 10);
      number /= 10;
    }
    return sum;
  }
}

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

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

    sort(A, A+N);

    for(long i=1; i<N; i++){
        if(A[i-1]==A[i]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 1792
import sys

def main():
  input = sys.stdin.readline
  N, K = map(int, input().split())
  
  if K % 2 == 1:
    ans = (N // K)**3
  else:
    ans = ((N + K//2) // K)**3 + (N // K)**3
    
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] sum = new long[N+1];
		for(int i=0;i<N;i++){
			sum[i+1] = sum[i] + A[i];
		}
		
		var L = new List<long>();
		for(int i=0;i<N;i++){
			for(int j=i+1;j<=N;j++){
				long s = sum[j] - sum[i];
				L.Add(s);
			}
		}
		L.Sort();
		
		for(int k=62;k>=0;k--){
			int cnt = 0;
			for(int i=0;i<L.Count;i++){
				if((L[i] >> k) % 2 == 1) cnt++;
			}
			var nL = new List<long>();
			if(cnt >= K){
				for(int i=0;i<L.Count;i++){
					if((L[i] >> k) % 2 == 1){
						nL.Add(L[i]);
					}
				}
				L = nL;
			}
		}
		
		long ans = L[0];
		for(int i=0;i<K;i++) ans &= L[i];
		Console.WriteLine(ans);
		
	}
	int N, K;
	long[] A;
	public Sol(){
		var d  = ria();
		N = d[0]; K = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 21728
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  long long N[3];
  cin >> N[0];
  cin >> N[1];
  cin >> N[2];
  sort(N, N + 3);
  if (N[2] % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << N[0] * N[1] << endl;
  return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

string s("CODEFESTIVAL2016") , t;

int main(){
  cin >> t;
  int dif = 0;
  rep(i,0,sz(t)) dif += s[i] != t[i];
  cout << dif << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
count =0
while(len(A)!=1):
    tmp_min_A = min(A)
    for i in range(1,len(A)):
        A[i] = A[i] % tmp_min_A
        if A[i] == 0:
            count +=1
    A.sort()
    for i in range(count):
        A.remove(0)
    count = 0
    
  
print(A[0])

Measured memory_bytes: 14252
abcd = input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
ans_list = []
if a+b+c+d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c+d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b-c+d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a+b-c-d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
else:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(10000) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int r, c, n;
int f(int x, int y){
    if(x > 0 && y == 0){
        return x;
    }
    else if(x == r && y > 0){
        return r + y;
    }
    else if(x > 0 && y == c){
        return r + c + (r - x);
    }
    else if(x == 0){
        return 2*r + c + (c-y);
    }
    else{
        return -1;
    }
}

int main() {
    cin >> r >> c >> n;
    vector<P> ls;
    for(int i=0;i<n;i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(f(x1,y1) >= 0 && f(x2,y2) >= 0){
            ls.push_back({f(x1, y1), i});
            ls.push_back({f(x2, y2), i});
        }
    }
    sort(ls.begin(), ls.end());
    stack<int> st;
    for(auto &p : ls){
        if(!st.empty() && st.top() == p.second){
            st.pop();
        }
        else{
            st.push(p.second);
        }
    }
    cout << (st.empty() ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 2420
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
if m == 0:
    if n == 1:
        print(0)
    else:
        print('1' + '0' * (n - 1))
    exit()
sc = [list(map(int, readline().split())) for i in range(m)]
sc.sort()
memo = sc[0]
if sc[0] == [1, 0] and n != 1:
    print(-1)
    exit()
for i in range(1, m):
    if memo[0] == sc[i][0]:
        if memo[1] != sc[i][1]:
            print(-1)
            exit()
    else:
        memo = sc[i]
ans = ''
for i in range(n):
    for j in range(m):
        if i + 1 == sc[j][0]:
            ans += str(sc[j][1])
            break
    if len(ans) != i + 1:
        if len(ans) == 0:
            ans += '1'
        else:
            ans += '0'
print(ans)


Measured memory_bytes: 3064
from collections import Counter
N = int(input())
words = [0]*N
for i in range(N):
    words[i] = input()
counter = Counter(words)
cnt = max(counter.values())
ans = []
for key,value in counter.items():
    if value == cnt:
        ans.append(key)
ans.sort()
print(*ans,sep="\n")

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    int n;
    cin >> n;
  	vi d(n);
  	rep(i,n) cin >> d[i];
	ll ans = 0;
  	rep(i,n-1){
    	rep3(j,i+1,n-1){
        	ans += d[i] * d[j];
        }
    }
  	cout << ans << endl;
  	return;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec A(n);
    ll k=0;
    rep(i,n) cin>>A[i];
    ll a=A[0],b=A[1];
    rep(i,n-2) k=k^A[i+2];
    if((a+b-k)%2||(a+b-k)<0){
        cout<<-1;
        return 0;
    }
    ll c=(a+b-k)/2;
    ll d=a+b-2*c;
    ll ans=c|d;
    if(c&d){
        cout<<-1;
        return 0;
    }
    vec C(61,0),D(61,0);
    for(int i=0;c>0;i++) C[i]=c%2,c/=2;
    for(int i=0;d>0;i++) D[i]=d%2,d/=2;
    int z=0;
    per(i,60){
        if(C[i]==1) continue;
        else{
            if(D[i]&&ans-pow(2,i)>=b) ans-=pow(2,i);
        }
    }
    if(ans>=A[1]&&ans-A[1]<A[0]) cout<<ans-A[1];
    else cout<<-1;
}

Measured memory_bytes: 4008
import java.util.*;

public class Main {
    private static class Union {
        int root[];

        public Union(int n) {
            root = new int[n];
            for (int i = 0; i < n; i++) {
                root[i] = i;
            }
        }

        public int root(int x) {
            return (root[x] == x) ? x : (root[x] = root(root[x]));
        }

        public void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx != ry) {
                root[rx] = ry;
            }
        }

        public boolean isSame(int x, int y) {
            return (root[x] = root(x)) == (root[y] = root(y));
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m];
        int b[] = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        Union uni = new Union(n);

        int cnt[] = new int[n];
        for (int i = 0; i < n; i++) {
            cnt[i] = 1;
        }

        long ans[] = new long[m + 1];
        ans[m] = ((long) n) * (n - 1) / 2;

        for (int i = m - 1; i >= 0; i--) {
            if (!uni.isSame(a[i], b[i])) {
                int ca = cnt[uni.root(a[i])];
                int cb = cnt[uni.root(b[i])];

                ans[i] = ans[i + 1] - ca * cb;

                cnt[uni.root(a[i])] = ca + cb;
                cnt[uni.root(b[i])] = ca + cb;
            } else {
                ans[i] = ans[i + 1];
            }
            uni.unite(a[i], b[i]);
        }

        for (int i = 1; i <= m; i++) {
            System.out.println(ans[i]);
        }
    }

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().main(sc);
        } catch (Exception e) {
            throw e;
        }
    }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    map<ll,ll> D;
    REP(i,0,N) {
        ll d;
        cin >> d;
        ++D[d];
    }
    ll M;
    cin >> M;
    map<ll,ll> T;
    REP(i,0,M) {
        ll t;
        cin >> t;
        ++T[t];
    }

    bool f = true;
    FORR(t,T) {
        if(D[t.first] < t.second) {
            f = false;
            break;
        } 
    }
    if(f) PR("YES");
    else PR("NO");

    return 0;
}

/*



*/

Measured memory_bytes: 28484
#include<bits/stdc++.h>
using namespace std;
const int N=50+5;
struct node{
	int x,y;
	node(int x=0,int y=0){
		this->x=x;
		this->y=y;
	}
};
queue<node> qe;
int n,m,sum;
char G[N][N];
bool vis[N][N];
int det[N][N];
int xx[]={0,0,-1,1};
int yy[]={1,-1,0,0};
int main(){
	scanf("%d %d",&n,&m);
	clock_t s=clock();
	for(int i=1;i<=n;++i){
		scanf("%s",G[i]+1);
		//for(int j=1;j<=m;++j) G[i][j]='.';
		for(int j=1;j<=m;++j)
			if(G[i][j]=='.') sum++;
	}
	if(G[1][1]=='#' || G[n][m]=='#'){
		puts("-1");return 0;
	}
	qe.push(node(1,1));
	while(!qe.empty()){
		node u=qe.front();qe.pop();
		//cout<<u.x<<" "<<u.y<<" "<<qe.size()<<"\n";
		vis[u.x][u.y]=true;
		for(int i=0;i<4;++i){
			int x=u.x+xx[i],y=u.y+yy[i];
			if(x<1 || x>n || y<1 || y>m) continue;
			if(vis[x][y] || G[x][y]=='#') continue;
			det[x][y]=det[u.x][u.y]+1;
			qe.push(node(x,y));vis[x][y]=true;
		}
	}
	if(vis[n][m]==0){
		puts("-1");return 0;
	}
//	cout<<sum<<" "<<det[n][m]+1<<"\n";
	printf("%d\n",sum-det[n][m]-1);
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
  string s;
  cin>>s;
  cout<<s[0]<<s.size()-2<<s[s.size()-1];
   return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {
	
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << -1 << endl;
	}
	else cout << a * b << endl;
	
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  ll cmp = 0;
  cmp = n % k;
  ans = min(cmp, abs(cmp-k));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main(void)
{
	int e;
	int x,y,z;
	int min;

	while(1){
		cin >> e;
		if (e==0) break;

		min = e;
		for(z=0;z*z*z<=e;z++){
			for(y=0;y*y<=e-z*z*z;y++){

				x = e - z*z*z - y*y;

				if(min>(x+y+z)){
					min = (x+y+z);
				}
			}
		}

		cout << min << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
/**
  * @file pa.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-09-29
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define N 131072
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int cnt[2][N];

int main()
{
    int n,k;
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&k), ++cnt[i&1][k];
    int *pe=std::max_element(cnt[0],cnt[0]+N),*po=std::max_element(cnt[1],cnt[1]+N);
    int ae=*pe,ao=*po;
    if(pe-cnt[0]!=po-cnt[1]) return printf("%d\n",n-ae-ao),0;
    *pe=*po=0;
    ae += *std::max_element(cnt[1],cnt[1]+N);
    ao += *std::max_element(cnt[0],cnt[0]+N);
    printf("%d\n",n-std::max(ae,ao));
    return 0;
}


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

int main(void){
    int i, N;
    cin >> N;
    int H[N];
    for(i=0; i<N; i++){cin >> H[i];}
    int max, ans;
    ans = 1;
    max = H[0];
    for(i=1; i<N; i++){
        if(max<=H[i]){
            ans++;
            max = H[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin>>n;
    vector<ll> a(n),A(n);
    rep(i,n){
        cin>>a[i];
        A[i]=a[i]-(i+1);
    }
    
    sort(all(A));
    int b=A[n/2];

    ll ans=0;
    rep(i,n){
        ans+=abs(a[i]-(b+i+1));
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 1e6 + 1;
ll dp[N][10][2][2]; 
void add(ll &a, ll b){
    a = (a + b) % MOD;
}
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;  
        for(i = 1; i <= 8; i++){
            dp[1][i][0][0] = 1;
        }  
        dp[1][0][1][0] = 1;
        dp[1][9][0][1] = 1;
        for(i = 2; i <= n; i++){
            for(j = 1; j <= 8; j++){
                for(ll prev = 0; prev <= 9; prev++){
                    add(dp[i][j][0][0], dp[i - 1][prev][0][0]);
                    add(dp[i][j][0][1], dp[i - 1][prev][0][1]);
                    add(dp[i][j][1][0], dp[i - 1][prev][1][0]);
                    add(dp[i][j][1][1] ,dp[i - 1][prev][1][1]);
                }
            }
            for(ll prev = 0; prev <= 9; prev++){
                add(dp[i][9][0][1] , (dp[i - 1][prev][0][0] + dp[i - 1][prev][0][1]));
                add(dp[i][9][1][1] , (dp[i - 1][prev][1][0] + dp[i - 1][prev][1][1]));
                add(dp[i][0][1][0] , (dp[i - 1][prev][0][0] + dp[i - 1][prev][1][0]));
                add(dp[i][0][1][1] , (dp[i - 1][prev][1][1] + dp[i - 1][prev][0][1]));
            }
        }
        ll ans = 0;
        for(i = 0; i <= 9; i++){
            ans += dp[n][i][1][1];
            ans %= MOD;
        }
        cout << ans;
    }
    return 0;
}

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



int main(){
	int n,maxx,minn;
	cin>>n;

	vector<int>a(n);

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

	maxx=a[1]-a[0];
	minn=a[0];
	
	for(int i=1;i<n;i++){
		minn=min(a[i-1],minn);
		maxx=max(a[i]-minn,maxx);

	}
	cout<<maxx<<endl;
	return 0;
}




Measured memory_bytes: 3552
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;
 
int main()
{
    string s;
    cin>>s;
    size_t size=s.length();
    int x=1;
    rep(i,size)
    {
        if(i%2==0)
        {
            if(s[i]=='L')
            {
                x=0;
                break;
            }
        }
        else
        {
            if(s[i]=='R')
            {
                x=0;
                break;
            }
        }
        
    }
    TF(x);
}

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

using namespace std;

using ll = long long;

constexpr ll INF = 1e17;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector< vector<ll> > dpL(2, vector<ll>(n + 1, -INF));
    dpL[false][0] = 0;
    for (int i = 0; i + 1 < n; i += 2) {
        dpL[false][i + 2] = max(dpL[false][i + 2], dpL[false][i] + a[i]);
        dpL[true][i + 2] = max(dpL[true][i + 2], max(dpL[false][i], dpL[true][i]) + a[i + 1]);
    }

    if (n % 2 == 0) {
        cout << max(dpL[false][n], dpL[true][n]) << "\n";
        return 0;
    }

    vector< vector<ll> > dpR(2, vector<ll>(n + 1, -INF));
    dpR[false][n - 1] = 0;
    for (int i = n - 1; i >= 2; --i) {
        dpR[false][i - 2] = max(dpR[false][i - 2], dpR[false][i] + a[i]);
        dpR[true][i - 2] = max(dpR[true][i - 2], max(dpR[false][i], dpR[true][i]) + a[i - 1]);        
    }

    ll ans = -INF;
    for (int i = 0; i < n; i += 2) {
        ans = max(ans, max(dpL[false][i], dpL[true][i]) + max(dpR[false][i], dpR[true][i]));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12520
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
// 1e18 + 5
#define INF 1000000000000000005
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll d, g;
  cin >> d >> g;
  
  vector<ll> p(d, 0), c(d, 0);
  for (int i = 0; i < d; i++){
    cin >> p[i] >> c[i];
  }
  
  int bit = 0;
  ll res = INF;
  while (bit < (2 << d)){
    vector<int> all(0), notall(0);
    ll score = 0, n = 0;
    for (int i = 0; i < d; i++){
      if ((bit >> i) & 1){
        all.emplace_back(i);
        score += (i + 1) * 100 * p[i] + c[i];
        n += p[i];
      }
      else {
        notall.emplace_back(i);
      }
    }

    int j = notall.size() - 1;
    while (j >= 0 && score < g){
      if (score + (notall[j] + 1) * 100 * (p[notall[j]] - 1) < g){
        score += (notall[j] + 1) * 100 * (p[notall[j]] - 1);
        n += p[notall[j]] - 1;
      }
      else {
        while (score < g){
          score += 100 * (notall[j] + 1);
          n++;
        }
      }
      j--;
    }

    if (score >= g)
      res = min(res, n);


    bit++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pii pair <int, int>
#define mp make_pair
#define F first
#define S second
#define ll long long
#define iosbase ios_base::sync_with_stdio(false)
#define sc scanf
#define pr printf
#define null NULL
#define getcx getchar_unlocked
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define pll pair<ll,ll>
#define vi vector <int>
#define vll vector <ll>
 
#define maxs 200005
#define logmaxs 35
 
#define MOD 1000000007
#define eps 1e-9
#define llmax 1e19+5
#define intmax 1e9+5
#define intmin -intmax
 
#define pi 3.14159265358979
 
using namespace std;

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans=llmax;
	ans=min(ans, b*c*abs((2*(a/2)-a)));
	ans=min(ans, a*c*abs((2*(b/2)-b)));
	ans=min(ans, b*a*abs((2*(c/2)-c)));
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        boolean yes = true;
        if(s.length() % 2 != 0){
            yes = false;
        }else{
            for(int i = 0; i < s.length(); i++){
                if(i%2 == 0){
                    if(s.charAt(i) != 'h'){
                        yes = false;
                    }
                }else{
                    if(s.charAt(i) != 'i'){
                        yes = false;
                    }
                }
            }
        }
        if(yes){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
#include<stdio.h>

int main(){
	int x1,x2,y1,y2;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	if(x1>=x2&&y1>=x2){
		for(int i=1;i<=(y2-y1);i++){
    		printf("D");
		}
   		for(int i=1;i<=(x2-x1);i++){
    		printf("L");
		}
   		for(int i=1;i<=(y2-y1);i++){
    		printf("U");
		}
    	for(int i=1;i<=(x2-x1);i++){
    		printf("R");
		}
		printf("R");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("D");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("L");
		}
	    printf("U");
	    printf("L");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("U");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("R");
		}
	    printf("D");
	}
	else if(x1<=x2&&y1<=y2){
		for(int i=1;i<=(y2-y1);i++){
    		printf("U");
		}
   		for(int i=1;i<=(x2-x1);i++){
    		printf("R");
		}
   		for(int i=1;i<=(y2-y1);i++){
    		printf("D");
		}
    	for(int i=1;i<=(x2-x1);i++){
    		printf("L");
		}
		printf("L");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("U");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("R");
		}
	    printf("D");
	    printf("R");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("D");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("L");
		}
	    printf("U");
	}
	else if(x1>=x2&&y1<=y2){
		for(int i=1;i<=(y2-y1);i++){
    		printf("U");
		}
   		for(int i=1;i<=(x2-x1);i++){
    		printf("L");
		}
   		for(int i=1;i<=(y2-y1);i++){
    		printf("D");
		}
    	for(int i=1;i<=(x2-x1);i++){
    		printf("R");
		}
		printf("R");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("U");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("L");
		}
	    printf("D");
	    printf("L");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("D");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("R");
		}
	    printf("U");
	}
	else if(x1<=x2&&y1>=y2){
		for(int i=1;i<=(y2-y1);i++){
    		printf("D");
		}
   		for(int i=1;i<=(x2-x1);i++){
    		printf("R");
		}
   		for(int i=1;i<=(y2-y1);i++){
    		printf("U");
		}
    	for(int i=1;i<=(x2-x1);i++){
    		printf("L");
		}
		printf("L");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("D");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("R");
		}
	    printf("U");
	    printf("R");
	    for(int i=1;i<=(y2-y1)+1;i++){
	    	printf("U");
		}
	    for(int i=1;i<=(x2-x1)+1;i++){
	    	printf("L");
		}
	    printf("D");
	}
}

Measured memory_bytes: 128
import math
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

L = make_divisors(n)
P = []
if math.sqrt(n) % 1 != 0:
    P.append(L[-1])
    P.append(L[-2])
else:
    P.append(L[-1])
    P.append(L[-1])

print(sum(P)-2)

Measured memory_bytes: 3268
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;
using Range = tuple<int, int>;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  vector<Range> ranges(n);
  Rep(i, n) {
    int x, l;
    cin >> x >> l;
    ranges[i] = make_tuple(x - l, x + l);
  }

  sort(
    ranges.begin(),
    ranges.end(),
    [](Range a, Range b) -> bool { return get<1>(a) < get<1>(b); }
  );

  int answer = 0;
  Range current = make_tuple(numeric_limits<int>::min(), numeric_limits<int>::min());
  for (Range r : ranges) {
    if (get<1>(current) <= get<0>(r)) {
      current = r;
      answer++;
    }
  }

  cout << answer << endl;

  return 0;
}


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

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

  if(n < 105){
    cout << '0' << endl;
    return 0;
  }

  int cnt = 0;
  for(int i = 105; i <= n; i++){
    if(i % 2 == 0) continue;

    int divisor = 0;
    for(int j = 1; j <= i; j++){
      if(i % j == 0) divisor++;
      if(divisor > 8) break;
    }

    if(divisor == 8) cnt++;
  }

  cout << cnt << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

LL gcd(LL x, LL y){
  LL sm, la, work;
  if(x<y) {
    la = y;
    sm = x;
  }
  else{
    la = x;
    sm = y;
  }

  while(1){
    work= la%sm;
    if(work==0)break;
    la=sm;
    sm=work;
  }
  return sm;
}

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

  LL leftg[n];
  LL rightg;
  LL a[n];
  REP(i, n) {
    cin>>a[i];
    if(i==0) leftg[i]=a[i];
    else leftg[i] = gcd(a[i], leftg[i-1]);
  }

  LL ans= 1;
  for(int i=n-1; i>-1; --i){
    if(i==n-1) {
      rightg = a[i];
      ans = leftg[i-1];
    }
    else if(i==0){
      ans = max(ans, rightg);
    }
    else {
      ans = max(ans, gcd(leftg[i-1], rightg));
      rightg = gcd(a[i], rightg);
    }

  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
	
	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			long N, M, sum = 0, cnt = 0;
			N = sc.nextLong();
			M = sc.nextLong();
			long[] Arr = new long[(int) N];
			for (int i = 0; i < N; i++) {
				Arr[i] = sc.nextInt();
				sum += Arr[i];
			}
			
			for(int i = 0; i<N; i++) {
				if(Arr[i]>=sum/4f/M) {
					cnt++;
				}
			}
			System.out.println(cnt<M?"No":"Yes");
	
		}
	}


Measured memory_bytes: 35844
m,d=map(int,input().split());ans=0
for i in range(1,m+1):
  for j in range(10,d+1):
    d1=int(str(j)[0]);d10=int(str(j)[1])
    if len(str(j))==2 and d1>=2 and d10>=2 and d1*d10==i:
      ans+=1
print(ans)

Measured memory_bytes: 9008
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
char c[62]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'};
int cnt=0,Cnt[62];
map<char,int> M; 
vector<string> v;
int id(char cha){
	return M[cha];
}
char cha(int id){
	return c[id];
}
int query(string s){
	cout<<"? "<<s<<endl;
	ff;
	int val;
	cin>>val;
	return val;
}
int len=0;
string merge(string s1,string s2){
	if(s2.length()<s1.length()){
		swap(s1,s2);	
	} 
	if(s1.length()==0) return s2;
	string res="",tmp="";
	int t1,t2;
	t1=t2=0;
	while(t1<s1.length()&&t2<s2.length()){
		tmp="";
		rep(i,t1+1){
			tmp+=s1[i];
		}
		rb(i,t2,s2.length()-1){
			tmp+=s2[i];
		}
		if(query(tmp)+tmp.length()==len){
			res+=s1[t1];
			t1++;
		}
		else{
			res+=s2[t2];
			t2++;
		}
	}
	while(t1<s1.length()){
		res+=s1[t1];
			t1++;
	}
	while(t2<s2.length()){
		res+=s2[t2];
			t2++;
	}
	return res;
}
int main(){
	fastio; 
	rb(i,1,26){
		M[char('a'+i-1)]=cnt++;
	}
	rb(i,1,26){
		M[char('A'+i-1)]=cnt++;
	}
	rb(i,1,10){
		M[char('0'+i-1)]=cnt++;
	}
	string tmp;
	rep(i,62){
		tmp="";
		rb(j,1,128){
			tmp+=c[i];
		}
		Cnt[i]=128-query(tmp);
		len+=Cnt[i];
	}
	rep(i,62){
		tmp="";
		rep(j,Cnt[i]){
			tmp+=c[i];
		}
		v.PB(tmp);
	}
	vector<string> Nex;
	while(v.size()>1){
		int L=v.size();
		rep(i,L){
			if(i+1<L){
				Nex.PB(merge(v[i],v[i+1]));
			}
			else{
				Nex.PB(v[i]);
			}
			i++;
		}
		v=Nex;
		Nex.clear();
	}
	cout<<"! "<<v[0]<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> l(N, 1), r(N, 1);
    l[0] = A[0];
    r[0] = A[N - 1];
    rep2(i, 1, N) {
        l[i] = __gcd(A[i], l[i - 1]);
    }
    rep2(i, 1, N) {
        r[i] = __gcd(A[N - 1 - i], r[i - 1]);
    }
    ll ans = 1;
    rep(i, N) {
        if (i == 0) {
            ans = max(ans, r[N - 2]);
        } else if (i == N - 1) {
            ans = max(ans, l[N - 2]);
        } else {
            ans = max(ans, __gcd(l[i - 1], r[N - 2 - i]));
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n, k; cin >> n >> k;
    set<int> snukes;
    int snuke;
    rep(i,k){
        cin >> snuke;
        rep(j,snuke){
            int x; cin >> x;
        snukes.insert(x);
        }
    }
    cout << n - snukes.size();
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<stack>
#include<cstring>
using namespace std;
const int M=1e9+7;
int main(){
	
	string s;
	cin>>s;
	int ans=0;
	for(auto x:s){
		ans+=x-'0';
	}
	if(ans%9==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3764
n,m = map(int,input().split())

a,b = ([0]*m,[0]*m)

for i in range(m):
    a[i],b[i] = map(int,input().split())

from collections import defaultdict

d = defaultdict(int)

for j in a:
    d[j] +=1
for k in b:
    d[k] +=1

for l in range(1,n+1):
    print(d[l])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N, i;
  cin >> N;
  
  int sum=0, min=9999;
  
  for(i=0;i<N;i++){
    int A;
    cin >> A;
    while(A%2 ==0){
      A /= 2;
      sum++;}
    if(min > sum){min = sum;}
    sum = 0;
  }
 cout << min << endl;   
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            # それぞれのコイン枚数に応じた合計額とXを比べる
            if i * 500 + j * 100 + k * 50 == X:
                ans += 1

print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

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

		String s1 = in.next(), s2 = in.next(), s3 = in.next();

		in.close();

		if(s1.charAt(s1.length() - 1) == s2.charAt(0) && s2.charAt(s2.length() - 1) == s3.charAt(0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;

    cin >> s;

    if (s <= "2019/04/30")
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;

    return 0;
}

Measured memory_bytes: 256