akhauriyash/Code-Regression huggingface dataset:
/* GRL_4_B */
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<list>
#include<queue>
#include<limits>
using namespace std;
const int maxn=100001;
const int Max_INF=numeric_limits<int>::max();
int n,m;
int indeg[maxn];                                //??\???
bool visited[maxn];
vector<int> G[maxn];
vector<int> out_put;

void topological_sort_bfs(int s)
{
    queue<int> q;
    q.push(s);
    visited[s]=true;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        out_put.push_back(u);
        for(int i=0;i<G[u].size();++i)
        {
            int v=G[u][i];
            indeg[v]--;
            if(indeg[v] == 0 && !visited[v])
            {
                q.push(v);
                visited[v]=true;
            }
        }
    }
}

int main()
{
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    scanf("%d%d",&n,&m);
    memset(visited,0,sizeof(visited));
    memset(indeg,0,sizeof(indeg));
    for(int i=0;i<m;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        indeg[v]++;
    }
    for(int u=0 ;u < n;++u)
      if(indeg[u] == 0 && !visited[u])
        topological_sort_bfs(u);
    int num=out_put.size();
    while(num)
    {
        printf("%d\n",out_put[out_put.size()-num]);
        num--;
    }
    return 0;
}

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

#define int long long

main(){

	int n,a,b;
	cin>>n>>a>>b;

	int aa=(n-1)*a+b;int bb=(n-1)*b+a;
	int ans=max((int)0,bb-aa+1);

	cout<<ans<<endl;

	return(0);
}


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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  const vector<vector<int>> groups = {
    { 1,3,5,7,8,10,12},
    { 4,6,9,11 },
    { 2 },
  };
  for (auto& group : groups) {
    if (count(begin(group), end(group), x) && count(begin(group), end(group), y)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    while(true) {
        int n = gi, x = gi;
        if (make_pair(n, x) == make_pair(0,0)) {
            break;
        }
        int res = 0;
        OneToN(i1, n) {
            AToB(i2, i1+1, n) {
                AToB(i3, i2+1, n) {
                    vec<int> list = {i1,i2,i3};
                    if (x == i1 + i2 + i3) {
                        res++;

                    }
                }
            }
        }
        print(res);
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll dp[100][100001];
ll w[100];
ll v[100];
int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ll n, c;
	cin >> n >> c;
	for (ll i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	dp[0][0] = 0;
	dp[0][w[0]] = v[0];
	for (ll i = 1; i < n; i++) {
		dp[i][0] = 0;
		for (ll j = 1; j <= c; j++) {
			{
				dp[i][j] = dp[i - 1][j];
				if (j >= w[i])
					dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);

			}
		}
	}
	ll ans = 0;
	for (ll i = 0; i <= c; i++) {
		ans = max(ans, dp[n - 1][i]);
	}
	cout << ans;
}


Measured memory_bytes: 80864
fun main(args: Array<String>) {
    abc055b()
}

private const val MOD = (1e9 + 7).toLong()
private fun mod(x: Long) = x % MOD

fun abc055b() {
    val n = readLine()!!.toInt()

    val answer = (1..n).fold(1L) { acc, i -> mod(acc * i) }

    println(answer)
}


Measured memory_bytes: 31808
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

int h[100000];

int main() {
    int n;
    cin >> n;
    rep(i, n) cin >> h[i];
    int ans = 0, cur = 0;
    rep(i, n - 1) {
        if(h[i] >= h[i + 1]) {
            cur++;
            ans = max(ans, cur);
        }else cur = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
<?php
fscanf(STDIN, "%d", $N);
$c = array_pad(array(), 100, 0);
for ($i = -1; $i <= 4; $i++) {
    if ($i === -1) {
        for ($j = 1; $j <= 9; $j++) {
            if ($N >= $j) {
                $c[$j * 11] = 1;
            }
        }
    } else {
        for ($j = 11; $j <= 99; $j++) {
            if ($j % 10 === 0) continue;
            $a = intdiv($j, 10);
            $b = $j - $a * 10;
            $t = $a * pow(10, $i + 1) + $b;
            //printf("%d %d\n", $j, $t);

            if ($N >= $t) {
                $tmp = $N - $t;
                $plus = min(intdiv($tmp, 10) + 1, pow(10, $i));
                // printf("%d %d %d %d\n", $j, $t, $tmp, $plus);
                $c[$j] += $plus;
            }
        }
    }

}
$ans = 0;
for ($j = 11; $j <= 99; $j++) {
    if ($j % 10 === 0) continue;
    $a = intdiv($j, 10);
    $b = $j - $a * 10;
    $d1 = $a * 10 + $b;
    $d2 = $b * 10 + $a;
    $ans += $c[$d1] * $c[$d2];
}
printf("%d", $ans);

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;

  if (B <= A)
    cout << "delicious" << endl;
  else if (B <= A + X)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N >> K;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<vector<int>>tapi(N, vector<int>(20, -1));
	vector<int>index(N, -1);
	vector<vector<int>>p(200001);
	for (int i = 0; i < N; i++) {
		index[i] = p[v[i]].size();
		p[v[i]].push_back(i);
	}
	for (int i = 0; i <= 200000; i++)p[i].push_back(-1);
	for (int i = 0; i < N; i++) {
		tapi[i][0] = p[v[i]][index[i] + 1] + 1;
		if (!tapi[i][0])tapi[i][0]--;
	}
	for (int j = 1; j < 20; j++) {
		for (int i = 0; i < N; i++) {
			if (tapi[i][j - 1] != -1 && tapi[i][j - 1] < N)tapi[i][j] = tapi[tapi[i][j - 1]][j - 1];
		}
	}
	vector<int>st(200001, -1);
	st[0] = 0;
	int bef = 0;
	int loop = 0;
	//cerr << "ohge";
	for (int i = 1 ; i <= 200002; i++) {
		int nx;
		if (!bef)nx = 0;
		else nx = p[bef][0] + 1;
		if (nx == N) {
			loop = i - st[0];
			break;
		}
		//cout << nx << endl;
		for (int j = 19; j >= 0; j--) {
			//cout << j << endl;
			if (nx<N&&tapi[nx][j] != -1)nx = tapi[nx][j];
			//cout << nx << endl;
		}
		//cout << nx << endl;
		if (nx == N) {
			loop = i - st[0];
			break;
		}
		bef = v[nx];
		if (st[v[nx]] == -1) {
			st[v[nx]] = i;
		}
		else {
			loop = i - st[v[nx]];
			break;
		}
	}
	//cerr << "ohe";
	K--;
	int cand = -1;
	for (int i = 0; i <= 200000; i++) {
		if (st[i] % loop == K % loop) {
			if (cand == -1)cand = i;
			else if (st[cand] < st[i])cand = i;
		}
	}
	vector<int>ret;
	if(cand)ret.push_back(cand);
	vector<int>place(200001, -1);
	if(cand)place[cand] = 0;
	for (int i = 0; i < N; i++) {
		if (place[v[i]] != -1 && place[v[i]] < ret.size() && ret[place[v[i]]] == v[i]) {
			ret.resize(place[v[i]]);
		}
		else {
			place[v[i]] = ret.size();
			ret.push_back(v[i]);
		}
	}
	for (auto i : ret)cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 39928
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = a[0];
  for(int i = n - 1; i > 0; --i){
    while(a[i] != 0 && ans != 0 && a[i] % ans != 0){
      a[i] %= ans;
      ans %= a[i];
    }
    if(ans == 0) ans = a[i];
  }
  cout << ans;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    private static long largerDigit(long a, long b) {
        return Math.max(String.valueOf(a).length(), String.valueOf(b).length());
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long min = 0;
        for (int i = 1; i <= Math.sqrt(n); i++) {
            if (n % i != 0) {
                continue;
            }
            long d = largerDigit(i, n / i);
            if (d < min || i == 1) {
                min = d;
            }
        }
        System.out.println(min);
    }

}


Measured memory_bytes: 21844
#include <cstdio>

using namespace std;

int main()
{
	int time;
	int h,m,s;
	
	scanf("%d", &time);
	
	h = time / 3600;
	time -= h * 3600;
	m = time / 60;
	time -= m * 60;
	s = time;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return (0);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef struct {
  int index;
  int *v;
} edge;

typedef struct {
  int d, v;
} distance;

int *va, *vb;
int *vertex_count;
bool *visited;
edge *undirected_graph;

distance visit(int vertex)
{
  distance r, t;

  r.d = 0;
  r.v = vertex;
  visited[vertex] = true;
  for (int i = 0; i < undirected_graph[vertex].index; i++) {
    if (!visited[undirected_graph[vertex].v[i]]) {
      t = visit(undirected_graph[vertex].v[i]);
      if (r.d <= t.d) {
        r.d = t.d + 1;
        r.v = t.v;
      }
    }
  }
  visited[vertex] = false;

  return r;
}

int main(void)
{
  int n;
  scanf("%d", &n);

  va = malloc(sizeof(int) * (n - 1));
  vb = malloc(sizeof(int) * (n - 1));
  vertex_count = calloc(n + 1, sizeof(int));
  undirected_graph = malloc(sizeof(edge) * (n + 1));
  visited = calloc(n + 1, sizeof(bool));

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

  for (int i = 0; i < n - 1; i++) {
    vertex_count[va[i]]++;
    vertex_count[vb[i]]++;
  }

  for (int i = 1; i <= n; i++) {
    undirected_graph[i].index = 0;
    undirected_graph[i].v = malloc(sizeof(int) * vertex_count[i]);
  }

  for (int i = 0; i < n - 1; i++) {
    undirected_graph[va[i]].v[undirected_graph[va[i]].index++] = vb[i];
    undirected_graph[vb[i]].v[undirected_graph[vb[i]].index++] = va[i];
  }

  puts(visit(visit(1).v).d % 3 == 1 ? "Second" : "First");

  for (int i = 1; i <= n; i++) {
    free(undirected_graph[i].v);
  }
  free(undirected_graph);
  free(va);
  free(vb);
  free(vertex_count);
  free(visited);
}


Measured memory_bytes: 21504
def solve(n):
    if n == 0:
        return '0'

    ans = ''
    p = 0
    d = 0
    while n + p:
        if (n & 1) ^ p:
            ans += '1'
            if d ^ p:
                p ^= 1
        else:
            ans += '0'
        n >>= 1
        d ^= 1

    return ans[::-1]


n = int(input())
print(solve(n))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	string s1,s2;
	cin >> s1 >> s2;
	long long ans=1;
	int left=1;
	for(int i=0;i<n;i++){
		if(s1[i]==s2[i]) {
			if(i==0) ans*=3;
			else if(left) ans*=2;
			else ans*=1;
			left=1;
		}
		else{
			if(i==0) ans*=6;
			else if(left) ans*=2;
			else ans*=3;
			i++;
			left=0;
		}
	}
	cout << ans%1000000007 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int long long int
#define pb push_back
#define M 1000000007
#define ff first
#define ss second
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<=n;i++)
#define FORR(a,b,c) for(int a= b;a>=c;a--)
#define fa(arrr) for(auto x:arrr)
#define iPair pair<int, pair<int,int>>
#define sz size()
// #define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define mxn 500005
#define PII pair<int,int>
#define aint(v) v.begin(), v.end()
#define endl "\n"
// #define N 1000
#define C 4
#define nfs ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
// Ordered Set Tree
// typedef tree<PII, null_type, less<PII>,
//         rb_tree_tag,
//         tree_order_statistics_node_update>
//         oset;
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

int fact[1005];

int power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = res * x % M;
		x = (x * x) % M;
		y = y / 2;
	}
	return res;
}


int modInv(int n) {
	return power(n, M - 2);
}
void facto() {
	fact[0] = 1;
	fact[1] = 1;
	for (int i = 2; i <= 1000; i++)
		fact[i] = (i * fact[i - 1]) % M;
}

int fermat(int n, int r) {
	return (fact[n] * modInv(fact[r]) % M * modInv(fact[n - r]) % M) % M;
}

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

bool isVaild(int x, int y) {
	if (x < 1 || x > N || y < 1 || y > N) return false;
	if (!vis[x][y]) return true;
	return false;
}



void solve() {
	int n, k;
	cin >> n;
	vector<int>arr(n),brr(n), crr(n);
	vector<int>dp1(n),dp2(n), dp3(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i] >> brr[i] >> crr[i];
	// cout << 0 <<endl;
	dp1[0] = arr[0];
	dp2[0] = brr[0];
	dp3[0] = crr[0];
	for(int i = 1;i<n;i++){
		dp1[i] = arr[i] + max(dp2[i-1], dp3[i-1]);
		dp2[i] = brr[i] + max(dp1[i-1], dp3[i-1]);
		dp3[i] = crr[i] + max(dp2[i-1], dp1[i-1]);
	}
	cout << max({dp1[n-1], dp2[n-1], dp3[n-1]}) << endl;
}


int32_t main()
{


	nfs;
	int t;
	// facto();
	// cin >> t;
	t = 1;
	while (t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 4992
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

n = int(input())
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

sum = 0
for i in range(1,n+1,2):
    temp = 0
    for j in range(1,i+1):
        if(i % j == 0):
            temp += 1
    if(temp == 8):
        sum += 1

print(sum)

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

int main()
{
    string s;
    cin >> s;

    //BCをDに変換したneを作成
    string ne = "";
    rep(i, s.length() - 1)
    {
        if (s[i] == 'B' && s[i + 1] == 'C')
        {
            ne += 'D';
            i++;
        }
        else
            ne += s[i];
    }
    if (ne[ne.length() - 1] != 'D')
        ne += s[s.length() - 1];

    ll ans = 0, cnt = 0;
    rep(i, ne.length())
    {
        if (ne[i] == 'A')
            cnt++;
        else if (ne[i] == 'D')
            ans += cnt;
        else
            cnt = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3916
import javax.management.Query;
import javax.print.attribute.SupportedValuesAttribute;
import java.io.*;
import java.lang.reflect.Array;
import java.security.interfaces.DSAKeyPairGenerator;
import java.util.*;
import java.util.function.Predicate;


public class Main {

    static class TaskB {

        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = in.nextIntArray(n);
            sort(arr);
            long cnt = 0;
            for(int i = 0; i < n; i++)
            {
                for(int g = i+1; g < n; g++)
                {
                    if(arr[g]==arr[i])continue;
                    for(int f = g+1; f < n; f++)
                    {
                        if(arr[g]==arr[f])continue;
                        if(arr[i]+arr[g]<=arr[f])
                        {
                            continue;
                        }
                        cnt++;
                    }
                }
            }
            out.print(cnt);
        }
    }


    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(in, out);
        out.close();
    }



    static void sort(int[] a)
    {
        ArrayList<Integer> list = new ArrayList<>();
        for(int i: a)list.add(i);
        Collections.sort(list);
        for(int i = 0; i < a.length; i++)a[i]=list.get(i);
    }


    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public InputReader(InputStream inputStream) {
            this.reader = new BufferedReader(
                    new InputStreamReader(inputStream));
        }

        public String next() {
            while (!tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
    }
}

Measured memory_bytes: 33076
def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    mae = A[0]
    for i in range(1, N):
        if mae > A[i]:
            ans += mae - A[i]
        mae = max(mae, A[i])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32368
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int W = stdIn.nextInt();
        int w[] = new int[N];
        int v[] = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = stdIn.nextInt();
            v[i] = stdIn.nextInt();
        }
        stdIn.close();
        Knapsack knapsak = new Knapsack();
        long max = knapsak.solve(w, v, W);
        System.out.println(max);
    }
}

class Knapsack {
    public long solve(int[] W, int[] P, int maxWeight) {
        long prev[] = new long[maxWeight + 1];
        long cur[] = new long[maxWeight + 1];

        for (int i = 0; i < W.length; i++) {
            for (int j = 0; j < cur.length; j++) {
                if (W[i] > j) {
                    cur[j] = Math.max(0, prev[j]);
                } else {
                    cur[j] = Math.max(prev[j], prev[j - W[i]] + P[i]);
                }
            }

            for (int k = 0; k < cur.length; k++) {
                prev[k] = cur[k];
            }
        }

        return cur[cur.length - 1];
    }
}


Measured memory_bytes: 24532
#!/usr/bin/env python3

# a 回目、b 回目を考えたとき、a mod K と b mod K の値が異なれば、a, b それぞれの回で独立に手を選べる。
# mod K の値に応じて、N 回のジャンケンを K 個のグループに分けたとき、各グループに対して、最大何点取れるかを考えればよい。
# あるグループで最大何点取れるかは、前回の手を覚えておきながら DP or 貪欲法で求めればよい。

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
# print(n, k, r, s, p, t)

t_list = list(t)
groups = [[] for i in range(k)]
for i in range(len(t_list)):
    mod = i % k
    groups[mod].append(t_list[i])
# print(groups)

def score(my_hand, hand):
    if my_hand == 'r' and hand == 's':
        return r
    elif my_hand == 's' and hand == 'p':
        return s
    elif my_hand == 'p' and hand == 'r':
        return p
    return 0

def get_win_hand(hand):
    if hand == 'r':
        return 'p'
    elif hand == 's':
        return 'r'
    else:
        return 's'

result = 0
# for each group
for i in range(k):
    hands = groups[i]
    # for each hand in a group
    for j in range(len(hands)):
        hand = hands[j]
        win_hand = get_win_hand(hand)
        if j == 0:
            my_hand = win_hand
        else:
            candidates = ['r', 's', 'p']
            candidates.remove(my_hand_prev)
            if win_hand == my_hand_prev:
                if j == len(hands) - 1:
                    candidates.pop()
                    my_hand = candidates[0]
                else:
                    hand_next = hands[j+1]
                    win_hand_next = get_win_hand(hand_next)
                    if win_hand_next == my_hand_prev:
                        candidates.pop()
                    else:
                        candidates.remove(win_hand_next)
                my_hand = candidates[0]
            else:
                my_hand = win_hand
        result += score(my_hand, hand)
        my_hand_prev = my_hand

print(result)


Measured memory_bytes: 14196
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		double b = sc.nextDouble();
		
		// 計算
		long result = 0;
		b += 0.001;
		long B = Double.valueOf(b*100).longValue();
		result = (a*B)/100;
		
		// 出力
		System.out.println(result);
	}

}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	string s,t; cin>>s>>t;
	for (int i=0; i<n; i++) {
		if(s.substr(i)==t.substr(0,n-i)) {
			string ret=s+t.substr(n-i);
			cout << ret.size() << endl;
			return 0;
		}
	}
	cout << s.size()+t.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;

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

    string s;
    cin >> s;
    vector <char> t;
    int cnt = 0;
    for (auto c : s) {
        if (!t.empty() && t.back() != c) {
            t.pop_back();
            cnt += 2;
        } else {
            t.push_back(c);
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#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)
using namespace std;
using ll = long long;

bool done(string s,char c) {
	for (char x:s) if (x!=c) return false;
	return true;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	string s;
	cin>>s;
	
	int res=sz(s);
	rep(i,0,26) {
		char c=char(i+'a');
		string t=s;
		int k=0;
//~ cerr<<t<<endl;
		while (!done(t,c)) {
			k++;
			string nt;
			rep(j,0,sz(t)-1) if (t[j]==c || t[j+1]==c) {
				nt+=c;
			} else {
				nt+=t[j];
			}
			t=nt;
//~ cerr<<t<<endl;
		}
		res=min(res,k);
	}
	cout<<res<<"\n";
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();

		Queue<Long> queue = new ArrayDeque<Long>();

		for (long i=1; i<=9; i++){
			queue.add(i);
		}

		for (int i=1; i<=k; i++){
			long poll = queue.poll();
			long amari = poll % 10;
			if (amari !=0) {
				queue.add(poll *10 + amari -1);
			}
			queue.add(poll * 10 + amari);
			if (amari !=9) {
				queue.add(poll * 10 + amari + 1);
			}
			if (i==k){
				System.out.println(poll);
			}
		}
	}
}

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    char X, Y;

    cin >> X >> Y;

    cout << (X < Y ? '<' : (X > Y ? '>' : '=')) << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define true 1
#define false 0

typedef unsigned long long int ulli;

int Rep(int i, int num) {

}

int main() {
	int h, w;
	int n;
	int a[10000];
	int map[100][100];
	scanf("%d %d %d", &h, &w, &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int color_num = 0;
	int color_element = a[color_num];
	int option = 1;
	for (int i = 0; i < h; i++) {
		for (int j = option ? 0 : w - 1; option ? j < w : j >= 0; option ? j++ : j--) {
			while (color_element == 0) {
				color_num++;
				color_element = a[color_num];
			}

			map[i][j] = color_num + 1;
			color_element--;
		}
		option = (option + 1) % 2;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			printf("%d ", map[i][j]);
		}
		printf("%d\n", map[i][w - 1]);
	}
	printf("\n");

	return 0;
}

/*

void MergeSort(int n, int x[], int y[]) {

	int buffer[1000];
	int buffer2[1000];

	int i, j, k, m;
	if (n <= 1) {
		return;
	}

	m = n / 2;

	MergeSort(m, x, y);
	MergeSort(n - m, x + m, y + m);

	for (i = 0; i < m; i++) {
		buffer[i] = x[i];
		buffer2[i] = y[i];
	}
	j = m;
	i = k = 0;
	while (i < m && j < n) {
		if (buffer[i] <= x[j]) {
			y[k] = buffer2[i];
			x[k++] = buffer[i++];
		}
		else {
			y[k] = y[j];
			x[k++] = x[j++];
		}
	}
	while (i < m) {
		y[k] = buffer2[i];
		x[k++] = buffer[i++];
	}
	return;
}*/

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct HASH{
	size_t operator () (const pair<int, int> &x) const {
		return hash<long long>()(((long long)(x.first)) ^ (((long long)(x.second)) << 32));
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll h, w, n;
	cin >> h >> w >> n;
	unordered_map<pi, ll, HASH> m;
	unordered_map<pi, int, HASH> vis; //to not count anything twice
	vector<ll> cnt(10, 0);
	vi a(n), b(n);
	rep(i, n){
		cin >> a[i] >> b[i];
		m[mp(a[i], b[i])]++;
	}
	rep(i, n){
		for(int j = a[i] - 2; j <= a[i]; j++){
			for(int k = b[i] - 2; k <= b[i]; k++){
				//check if it is a valid square (and not visited)
				if(!(j >= 1 && k >= 1 && (j + 2) <= h && (k + 2) <= w && !vis[mp(j, k)])) continue;
				//count
				int num = 0;
				repn(l, j, j + 3) repn(p, k, k + 3) if(m[mp(l, p)]) num++;
				vis[mp(j, k)] = 1;
				cnt[num]++;
			}
		}
	}
	ll tot = 0;
	repn(i, 1, 10) tot += cnt[i];
	cnt[0] = (ll)(1LL * ((h - 2) * (w - 2)) - tot);
	rep(i, 10) cout << cnt[i] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 202712
import math
l=[int(input()) for i in range(5)]
t=[]
for ll in l:
  t.append(math.ceil(ll/10))
lis=[]
for i in range(5):
  lis.append(t[i]*10-l[i])
m=max(lis)
sum=0
for i in range(5):
  sum+=t[i]*10
print(sum-m)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){

    int N;
    cin >> N;

    int count = 0;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        if (a % 2 != 0){
            count += 1;
        }
    }
    
    if (count % 2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    cin >> s;
    cout << "A" << s[0] << "C" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long n, a[200000], s[200000], minx, miny, A, B, C, B2, C2, sum, d, e, f[3], g;
int main() {
	long long Left,Right,Mid;
	cin >> n;
	for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; }
	for (int i = 1; i <= n; i++) { s[i] = s[i - 1] + a[i]; }
	for (int i = 0; i <= n; i++) {
		A = s[i];
		B = (s[i] + sum / 3) % sum;
		C = (s[i] + sum * 2 / 3) % sum;

		Left=i;Right=n+1;

		for(int j=0;j<100;j++){
			Mid=(Left+Right)/2;
			if(s[(Mid - 2)%n + 1]>=B){
				Right=Mid;
			}
			if(s[(Mid - 1)%n + 1]<B){
				Left=Mid + 1;
			}
		}

		B2 = s[(Mid - 1) % n + 1]; d = (Mid - 1) % n + 1;

		Left=i;Right=n+1;

		for(int j=0;j<100;j++){
			Mid=(Left+Right)/2;
			if(s[(Mid - 2)%n + 1]>=C){
				Right=Mid;
			}
			if(s[(Mid - 1)%n + 1]<C){
				Left=Mid + 1;
			}
		}

		C2 = s[(Mid - 1) % n + 1]; e = (Mid - 1) % n + 1;

		f[0] = i; f[1] = d; f[2] = e;
		sort(f, f + 3);
		g = f[0]; d = f[1]; e = f[2];
		miny = min(s[d] - s[g], s[e] - s[d]);
		miny = min(miny, sum - (s[e] - s[g]));
		minx = max(minx, miny);

		if (d - 1 >= 0) {
			miny = min(s[d - 1] - s[g], s[e] - s[d - 1]);
			miny = min(miny, sum - (s[e] - s[g]));
			minx = max(minx, miny);
		}
		if (e - 1 >= 0) {
			miny = min(s[d] - s[g], s[e - 1] - s[d]);
			miny = min(miny, sum - (s[e - 1] - s[g]));
			minx = max(minx, miny);
		}
		if (d - 1 >= 0 && e - 1 >= 0) {
			miny = min(s[d - 1] - s[g], s[e - 1] - s[d - 1]);
			miny = min(miny, sum - (s[e - 1] - s[g]));
			minx = max(minx, miny);
		}
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 2728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
    int R,G,B,N,ans=0;
    cin>>R>>G>>B>>N;
    for(int r=0;r*R<=N;++r)
        for(int g=0;r*R+g*G<=N;++g)
        {
            if(((N-r*R-g*G)%B)==0) ++ans;
        }
    cout<<ans;
    return 0;
}


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

int cnt, m, g[13] = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161};

void insertionSort(int a[], int n, int g){
	for(int i = g; i < n; i++){
		int v = a[i], j = i-g;
		while(j >= 0 && a[j] > v){
			a[j+g] = a[j];
			j = j-g;
			cnt++;
		}
		a[j+g] = v;
	}
}

void shellSort(int a[], int n){
	cnt = 0;
	m = 0;
	for(int i = 0; i < 13; i++){
		if(g[i] <= n)
			m++;
	}
	for(int i = m-1; i >= 0; i--)
		insertionSort(a, n, g[i]);
}

void print(int a[], int n){
	cout << m << endl << g[m-1];
	for(int i = m-2; i >= 0; i--)
		cout << ' ' << g[i];
	cout << endl << cnt << endl;
	for(int i = 0; i < n; i++)
		cout << a[i] << endl;
}

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


Measured memory_bytes: 7016
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#define int long long
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define veb vector<bool>
#define pin pair<int,int>
#define mp make_pair 
#define int long long
using namespace std;
void mmin(int &a, int b) { a = min(a, b);}
signed main() {
	int n; cin >> n;
	vel w(n); vel b(n);
	int p; cin >> p;
	int sum = 0;
	vel cha(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> b[i];
		sum -= b[i] * p;
		cha[i] = w[i] * 100 - (w[i] - b[i])*p;
		w[i] *= 100; b[i] *= 100;
	}
	sort(cha.rbegin(), cha.rend());
	int i = 0;
	while (sum < 0) {
		sum += cha[i]; i++;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long int
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
const double PI = 3.141592653589793238;

int n;

VI node[100010];

int farest[10][100010];
void solvefar(int nm, int now, int times)
{
  if(farest[nm][now] == -1){
    farest[nm][now] = times;
    for(int i = 0; i < node[now].size(); i++){
      solvefar(nm, node[now][i], times + 1);
    }
  }
}

signed main()
{
  scanf("%lld", &n);
  for(int i = 0; i < n - 1; i++){
    int u, v;
    scanf("%lld%lld", &u, &v);
    node[u].PB(v);
    node[v].PB(u);
  }

  memset(farest, -1, sizeof farest);
  
  solvefar(0, 1, 0);

  int far1 = 0, mx1 = 0;
  for(int i = 1; i <= n; i++){
    if(mx1 < farest[0][i]){
      far1 = i;
      mx1 = farest[0][i];
    }
  }
  
  solvefar(1, far1, 0);

  int far2 = 0, mx2 = 0;
  for(int i = 1; i <= n; i++){
    if(mx2 < farest[1][i]){
      far2 = i;
      mx2 = farest[1][i];
    }
  }

  solvefar(2, far2, 0);

  for(int i = 1; i <= n; i++){
    farest[3][i] = max(farest[1][i], farest[2][i]);
  }
  

  for(int i = 1; i <= n; i++){
    printf("%lld\n", farest[3][i] + (n - 1 - farest[3][i]) * 2);
  }

  return 0;
}

Measured memory_bytes: 19176
#include <stdio.h>
int w[25],i,d,t[]={1,5,-1,-5};
int main(void){
	for(i=0;i<9;i++){
		if(i&1)for(d=0;d<5;d++)getchar()-'0'?w[i/2*5+d]|=2,w[i/2*5+d+5]|=8:0;
		else for(d=0;d<4;d++)getchar()-'0'?w[i/2*5+d]|=1,w[i/2*5-~d]|=4:0;
		getchar();
	}
	d=!putchar('R');
	for(i=1;d|i;d&=3)
		w[i]&1<<d?i+=t[d],putchar("RDLU"[d]),w[i]&1<<(d+3&3)&&--d:++d;

	i=!puts("");
}

Measured memory_bytes: 0
#include<iostream>
#include <bits/stdc++.h>
//1000000000000223
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N=1e5+9;
int n, ans[N], l[N], r[N], k, vis[N];
vector<int>v[N];
void dfs(int node, int p)
{
    l[node]=max(l[node],l[p]-1);
    r[node]=min(r[node],r[p]+1);
    for(auto i : v[node])
        if(i!=p)
        {
            dfs(i,node);
            l[node]=max(l[node],l[i]-1);
            r[node]=min(r[node],r[i]+1);
        }
    if(l[node]>r[node])
    {
        cout<<"No";
        exit(0);
    }
}
void solve(int node, int p)
{
    //cout<<l[node]<<" "<<r[node]<<endl;
    if(!vis[node])
    {
        if(l[node]!=ans[p])
            ans[node]=l[node];
        else if(l[node]+1<=r[node])
            ans[node]=l[node]+1;
        else
        {
            cout<<"No";
            exit(0);
        }
    }
    vis[node]++;
    for(auto i : v[node])
        if(i!=p)
        {
            l[i]=max(ans[node]-1,l[i]);
            r[i]=min(ans[node]+1,r[i]);
            solve(i,node);
        }
}
int main()
{
    IO
    cin>>n;
    for(int i=0; i<=n; i++)
        l[i]=-1e9, r[i]=1e9;
    for(int i =1; i<n; i++)
    {
        int x, y;
        cin>>x>>y;
        v[x].push_back(y), v[y].push_back(x);
    }
    int x, y;
    cin>>k;
    while(k--)
    {
        cin>>x>>y;
        vis[x]=1;
        ans[x]=l[x]=r[x]=y;
    }
    dfs(x,0);
    solve(x,0);
    ans[0]=ans[x]-1;
    cout<<"Yes";
    for(int i=1; i<=n; i++)
        cout<<"\n"<<ans[i];
    return 0;
}


Measured memory_bytes: 14208
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
LL a[100001],l[100001],r[100001];

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

int main(){
      
  fastio();
  LL n,m,i,j,ans=0;
  cin>>n;
  for(i=0;i<n;i++)
  {
  	cin>>a[i];
  }
  l[0]=a[0];
  r[n-1]=a[n-1];
  
  for(i=1;i<n;i++)
  	l[i]=gcd(a[i],l[i-1]);

  for(i=n-2;i>=0;i--)
  	r[i]=gcd(a[i],r[i+1]);
  
  for(i=1;i<n-1;i++)
  {
  	ans=max(ans,gcd(l[i-1],r[i+1]));
  }
  ans=max(ans,l[n-2]);
  ans=max(ans,r[1]);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;


int F[45];

int main() {
  F[0] = 1;
  F[1] = 1;
  for (int i = 2; i < 45; ++i) {
    F[i] = F[i-1] + F[i-2];
  }

  int input;
  cin >> input;
  cout << F[input]<< endl;
}
  

Measured memory_bytes: 1164
package main

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

func main() {
	n := readi()
	q := readi()
	s := readString()
	l := make([]int, q)
	r := make([]int, q)
	for i := 0; i < q; i++ {
		l[i] = readi()
		r[i] = readi()
	}

	cnt := 0
	ac := make(map[int]int)
	for i := 0; i < n-1; i++ {
		if string(s[i]) == "A" && string(s[i+1]) == "C" {
			cnt++
		}
		ac[i+1] = cnt
	}

	for i := 0; i < q; i++ {
		fmt.Println(ac[r[i]-1] - ac[l[i]-1])
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

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

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 9600
N = int(input())
travel = [input().split() for _ in range(N)]
t, x, y = 0, 0, 0
for i in range(N):
    if ((int(travel[i][0]) - t) - (abs(x - int(travel[i][1])) + (abs(y - int(travel[i][2]))))) % 2 != 0:
        print("No")
        exit()
    if (int(travel[i][0]) - t) < (abs(x - int(travel[i][1])) + (abs(y - int(travel[i][2])))):
        print("No")
        exit()
    t, x, y = int(travel[i][0]), int(travel[i][1]), int(travel[i][2])
print("Yes")

Measured memory_bytes: 32144
#include<stdio.h>
#define SQ(x) ((x)*(x))
#define min(x, y) ((x)>(y)?(y):(x))
#define max(x, y) ((x)<(y)?(y):(x))
typedef long long ll;
struct Point{
	int x,y;
}p1,p2,p3,p4;
Point vector(Point p1,Point p2){
	Point res;
	res.x = p2.x-p1.x;
	res.y = p2.y-p1.y;
	return res;
}
int dot(Point p1, Point p2){ return p1.x*p2.x+p1.y*p2.y; }
int cross(Point p1, Point p2){ return p1.x*p2.y-p1.y*p2.x; }
ll lengthSQ(Point vec){ return SQ(ll(vec.x))+SQ(ll(vec.y)); }
int loc(Point pt0, Point pt1, Point pt2){
	Point vec1 = vector(pt0, pt1);
	ll vec1Len2 = lengthSQ(vec1);
	Point vec2 = vector(pt0, pt2);
	int cro = cross(vec1, vec2);
	if(cro>0) return -1;// a×b>0，则b在a的逆时针方向
	else if(cro<0) return 1;// a×b<0，则b在a的顺时针方向
	else if(dot(vec1, vec2)<0) return -1;// a×b=0, a·b<0，则a、b方向相反
	else if(lengthSQ(vec2)>vec1Len2) return 1;
	else return 0;
}
void solve(){
	if(loc(p1, p2, p3) * loc(p1, p2, p4)<=0 && 
		loc(p3, p4, p1) * loc(p3, p4, p2)<=0) printf("1\n");
	else printf("0\n");
}
bool rectDiv(){// 返回线段所在矩形是否相交
	if(max(p1.x, p2.x)<min(p3.x, p4.x) ||
		min(p1.x, p2.x)>max(p3.x, p4.x) ||
		max(p1.y, p2.y)<min(p3.y, p4.y) ||
		min(p1.y, p2.y)>max(p3.y, p4.y))
		return false;
	else return true;
}
int main(){
	int q;
	scanf("%d", &q);
	while(q--){
		scanf("%d%d%d%d%d%d%d%d", &p1.x, &p1.y, &p2.x, &p2.y, &p3.x, &p3.y, &p4.x, &p4.y);
		if(rectDiv()) solve();
		else printf("0\n");
	}
}


Measured memory_bytes: 2656
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        while(true){
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x == 0 && y == 0){
            break;
        }
        System.out.println(Math.min(x,y)+" "+Math.max(x,y));
        }
    }
}

Measured memory_bytes: 35332
// time-limit: 2000
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cout << coutc << e;
  ((cout << " " << r), ..., (cout << endc << endl));
}
#else
#define debug(...)
#endif

int sign(li x) { return x < 0 ? -1 : x > 0; }

//         a / b
li ceil(li a, li b) {
  if (sign(a) == sign(b) && a % b) return a / b + 1;
  else return a / b;
}

void _main(int tc) {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return;
    }
    
    if (b <= a) {
        cout << 1 << endl;
        return;
    }

    cout << ceil(b - a, a - 1) + 1 << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main(){
	int a,b,c,d,sum=0;
	cin>>a>>b>>c>>d;
	for(int i=1;i<=a;i++){
		if(i>b)sum+=d;
		else sum+=c;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256