akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextInt();
        double b = sc.nextInt();
        double x = sc.nextInt();

        double tanq = -1;
        if (x / a > a * b / 2.0) {
            tanq = 2.0 * b / a - 2.0 * x / a / a / a;
            // System.out.println(1);
        } else {
            tanq = a * b * b / 2.0 / x;
            // System.out.println(3);
        }

        double q = Math.atan(tanq) * 180.0 / Math.PI;
        System.out.println(q);

        sc.close();
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n,n3,n5,n15,ans;
  cin>>n;
  n3=n/3;
  n5=n/5;
  n15=n/15;
  ans=n*(n+1)/2+15*n15*(n15+1)/2-3*n3*(n3+1)/2-5*n5*(n5+1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N;
	cin >> N;
	string a, b, c;
	cin >> a >> b >> c;

	int ans = 0;
	for (int ii = 0; ii < N; ++ii){
		map<char, int> m;
		m[a[ii]]++;
		m[b[ii]]++;
		m[c[ii]]++;

		int maxVal = max(m[a[ii]], max(m[b[ii]], m[c[ii]]));
		ans += 3 - maxVal;
	}


		cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long ll;



void swap (int *x, int *y) {
    int temp;    
    
    temp = *x;
    *x = *y;
    *y = temp;
}

int partition (int array[], int left, int right) {
    int i, j, pivot;
    i = left;
    j = right + 1;
    pivot = left;
    
    do {
        do { i++; } while (array[i] < array[pivot]);
        do { j--; } while (array[pivot] < array[j]);
        
        if (i < j) { swap(&array[i], &array[j]); }
    } while (i < j);
    
    swap(&array[pivot], &array[j]);
    
    return j;
}

void quick_sort (int array[], int left, int right) {
    int pivot;
    
    if (left < right) {
        pivot = partition(array, left, right);
        quick_sort(array, left, pivot-1);
        quick_sort(array, pivot+1, right);
    }
}
int main(void){
    
    int N;
    cin >> N;
    int d[N];
    
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    
    quick_sort(d, 0, N-1);
    
    int number;
    number = d[N/2] - d[N/2 -1];
    
    
    cout << number <<endl;
    

}


Measured memory_bytes: 640
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])


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

int main(){

    long int a,b,c,d,p;
    cin >> a >> b >> c >> d >> p;

    if(p<=c){
        if(a*p<=b){
        cout << a*p;
        }else if(a*p>=b){
        cout << b;
        }
    }

    if(p>c){
      if(a*p>=b+(p-c)*d){
      cout << b+(p-c)*d;
        }else if (a*p<b+(p-c)*d){
        cout << a*p;
        }
    }
    



    cout << endl;

    return 0;
}


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

int main() {
  int N, Y;
  cin >> N >> Y; Y /= 1000;
  for (int i=0; i<=N; i++) {
    for (int j=0; i+j<=N; j++) {
      if (i*10 + j*5 + (N-i-j) == Y) {
        cout << i << " " << j << " " << (N-i-j) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,q;
  cin >> n >> q;
  fenwick_tree<ll> fw(n);
  for(int i = 0; i < n; ++i){
    ll a;
    cin >> a;
    fw.add(i,a);
  }
  while(q--){
    int op;
    cin >> op;
    if(op == 0){
      int pos;
      ll val;
      cin >> pos >> val;
      fw.add(pos,val);
    }
    else{
      int l,r;
      cin >> l >> r;
      cout << fw.sum(l,r) << '\n';
    }
  }
  return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(b/a, c) << endl;
    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i < n;i++){
    cin >> p.at(i);
  }
  
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i < k;i++){
    ans += p.at(i);
  }
  cout << ans << endl;
}



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

int main() {

    int n, m; cin >> n >> m;
	const int p = 51;
	vector<int> num(p, 0);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		num[a - 1]++;
		num[b - 1]++;
	}
	for (int i = 0; i < n; i++) {
		cout << num[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main()
{
    string s;
    getline(cin,s);
    int t=s.length()-2;
    printf("%c%d%c",s[0],t,s[s.length()-1]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string in, out; getline(cin, in); out = "";

  int diff = 'a' - 'A';
  for (string::iterator itr = in.begin();
       itr != in.end(); itr++) {
    char c = *itr;
    if ('a' <= c && c <= 'z') {
      c = c-diff;
    } else if ('A' <= c && c <= 'Z') {
      c = c+diff;
    }
    out += c;
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 1180
/*****include*****/
#include <iostream>
#include <string>
/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
/*****変数置き場*****/
	string table[] = {
		"* = ****",
		"* =* ***",
		"* =** **",
		"* =*** *",
		"* =**** ",
		" *= ****",
		" *=* ***",
		" *=** **",
		" *=*** *",
		" *=**** "
	};
	string answer[5];
	int number;
	int k=0;
	int dummy = 0;
	/*****処理部*****/
	while(1){
		cin >> number;
		if(cin.eof())	break;
		k=4;
		for(int i=1;i<=10000;i*=10){
			answer[k] = table[(number/i)%10];
			//cout << (number/i)%10 << endl;
			k--;
		}
		if(dummy!=0)	cout << endl;
		else			dummy = 1;
		for(int i=0;i<8;i++){
			for(int j=0;j<5;j++){
				cout << answer[j][i];
			}
			cout << endl;
		}
	}
	/*****処理終了後*****/
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=0;
	for(ll i=0;i<n-1;i++)
	{
		if(a[i+1]<a[i])
		{
			ans+=abs(a[i]-a[i+1]);
			a[i+1]=a[i];
		}
	}
	cout<<ans;
	return;
}

int main()
{
	fast;
	ll q;
	q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
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; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    for (int i = 0; i < k; i++) {
        int m;
        cin >> m;
        for (int j = 0; j < m; j++) {
            int id;
            cin >> id;
            a[--id]++;
        }
    }
    
    int ans = 0;
    for (int &e : a) if (e == 0) ans++;
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN=200005;
int a[MAXN],N;
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		int tmp; scanf("%d",&tmp);
		a[tmp]=i;
	}
	int ans=0,now=0;
	for(int i=1;i<=N;i++){
		if(a[i]<a[i-1]){
			if(i!=1) now=1;else now=0;
		}else{
			now++;
			ans=max(ans,now);
		}
	}
	printf("%d\n",N-ans);
	return 0;
}


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

using namespace std;
#define EB emplace_back
#define MP make_pair
typedef long long ll;
#define rep(i, a, b) for(ll i = a; i < b; ++i)

ll calc(ll h){
    if(h == 1)
        return 1;
    ll res =  calc(h/2);
    res += res;

    return res + 1;
}

int main() {

   ll h;
   cin >> h;

   ll moves = calc(h);
   cout << moves;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
    public void Solve() {
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int ruisekiwa[] = new int[n + 1];
        for (int i = 0; i < ruisekiwa.length - 2; i++) {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        }
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 84644
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) n % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std; 

int main() { 
    IOS;
    ll n, k;
    cin >> n >> k;
    vll h(n);
    vll cost(n, 10000000000);
    cost[0] = 0;
    for (int i = 0; i < n; i++) {
    	cin >> h[i];
    	for (int j = max((ll)0, i - k); j < i; j++) {
    		cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j]));
    	}
    }
    cout << cost[n - 1] << endl;
}   

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n1 = in.nextInt();
        int n2 = in.nextInt();
        int sum = 0;
        while (n1 <= n2){
            if(isPalindrome(n1)){
                sum++;
            }
            n1++;
        }
        System.out.println(sum);
    }

    private static boolean isPalindrome(int n1) {
        String str = Integer.toString(n1);
        StringBuilder sb = new StringBuilder();
        sb.append(str);
        return sb.reverse().toString().equals(str);
    }
}

Measured memory_bytes: 38200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/
/*ll lcs(string a,string b,ll n,ll m){
    ll dp[n+1][m+1];
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0|| j==0)
                dp[i][j]=0;
            else if(a[i]==b[j])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    return dp[n][m];

}*/
/*ll editDist(string a,string b,ll n,ll m){
    vector<vector<ll> >dp(n+1,vector<ll>(m+1,-1));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0)
                dp[i][j]=j;
            else if(j==0)
                dp[i][j]=i;
            else if(a[i]==b[j])
                dp[i][j]=dp[i-1][j-1];
            else{
                dp[i][j]=1+min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]));
            }
        }
    }
    return dp[n][m];
}*/

/*ll d1(vector<string>a,ll n,ll m,vector<vector<ll> >dp){
    if(n<0 || m<0 ) return 0;
    if(n==0 && m==0) return 0;
    if(a[n][m]=='#') dp[n][m]=0;
    if((n==0 &&m==1) || (m==0&&n==1)) return 1 ;
    if(dp[n][m]!=-1)
        return dp[n][m];

    dp[n][m]=d(a,n-1,m,dp)+d(a,n,m-1,dp);
    return dp[n][m];
}*/
ll solve(ll a[],ll n){
    ll l=0,r=n-1;
        while(a[l+1]>a[l] && l<n-1){
            l++;
        }
        while(a[r-1]<a[r] && r-1>=0){
            r--;
        }
        if(r==n-1 && l==0){
            cout<<"yes"<<endl;
            cout<<1<<" "<<n;
        }


}
int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll dp[n+1];
    memset(dp,10004,sizeof(dp));
    dp[0]=0;dp[1]=0;
    for(ll i=2;i<=n;i++){
        for(ll j=1;j<i && j<=k;j++){
            dp[i]=min(dp[i],abs(a[i-1]-a[i-1-j])+dp[i-j]);
        }
    }
    //for(ll i=0;i<=n;i++) cout<<dp[i]<<" ";
    cout<<dp[n];
}


Measured memory_bytes: 4844
def check(setting, switch, offset):
    output = setting & switch
    count = 0
    while output > 0:
        count += output & 1
        output >>= 1
    return count % 2 == offset


N, M = map(int, input().split())
switch_state_num = 1 << N

lamp_setting = []
lamp_default = []

# ランプの設定の入力もバイナリの配列にしちゃう
for _ in range(M):
    lamp_setting_input = (list(map(int, input().split())))[1:]
    lamp_setting_single = 0
    for i in range(N):
        lamp_setting_single |= (1 if (i + 1) in lamp_setting_input else 0) << i
    lamp_setting.append(lamp_setting_single)

lamp_default = list(map(int, input().split()))

ans = 0

# ループの最大は所詮 2**10→1024。桁が2つ3つ増えたってゴリ押し可能。
for switch_state in range(switch_state_num):
    suc = True
    for lamp_index in range(M):
        if not check(lamp_setting[lamp_index], switch_state, lamp_default[lamp_index]):
            suc = False
            break
    if suc:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
int a,b;
char s[10],t[10],u[10];
scanf("%s %s",&s,&t);
scanf("%d %d",&a,&b);
scanf("%s",&u);
if(s[0]==u[0])
  a--;
else
  b--;
printf("%d %d",a,b);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
int n,m,ans;
char c[2005][2005];
bool ok[2005][2005];
int h[2005];
bool check(int x,int y){
	int cnt=0;
	if (c[x][y]=='#'){
		cnt++;
	}
	if (c[x+1][y]=='#'){
		cnt++;
	}
	if (c[x][y+1]=='#'){
		cnt++;
	}
	if (c[x+1][y+1]=='#'){
		cnt++;
	}
	if (cnt==1 || cnt==3){
		return false;
	}
	else{
		return true;
	}
}
int main(){
	cin>>n>>m;
	ans=n;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			cin>>c[i][j];
		}
	}
	memset(ok,true,sizeof(ok));
	for (int i=1;i<n;i++){
		for (int j=1;j<m;j++){
			if (check(i,j)){
				ok[i][j]=true;
			}
			else{
				ok[i][j]=false;
			}
		}
	}
/*	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++){
			cout<<ok[i][j];
		}
		cout<<endl;
	}
	cout<<endl;*/
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m-1;j++){
			if (i==1){
				h[j]=1;
			}
			else{
				if (ok[i-1][j]){
					h[j]++;
				}
				else{
					h[j]=1;
				}
			}
		}
	/*	for (int j=1;j<=m-1;j++){
			cout<<h[j]<<" ";
		}
		cout<<endl;*/
		stack<int> stk;
		for (int j=1;j<=m;j++){
			while (!stk.empty() && h[stk.top()]>=h[j]){
				int pl=stk.top();
				stk.pop();
				int wde;
				if (stk.empty()){
					wde=j;
				}
				else{
					wde=j-stk.top();
				}
				ans=max(ans,wde*h[pl]);
			}
			stk.push(j);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8064
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }

fn main() {
    input! {
        n: usize,
        mut a: [i64; 3 * n]
    }
    a.sort();
    let mut sum :i64 = 0;
    for i in 0..n {
        sum += a[n + 2 * i];
    }
    println!("{}", sum);
}


Measured memory_bytes: 13560
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

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

    Int n;
    cin >> n;

    vector<Int> a(n), l(n), r(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        if (i != 0) {
            l[i] = Gcd(a[i], l[i - 1]);
        } else {
            l[i] = a[i];
        }
    }

    r[n - 1] = a[n - 1];
    for (Int i = n - 2; i >= 0; --i) {
        r[i] = Gcd(a[i], r[i + 1]);
    }

    Int ans = r[1];
    for (Int i = 1; i < n - 1; i++) {
        ans = max(ans, Gcd(l[i - 1], r[i + 1]));
    }
    ans = max(ans, l[n - 2]);

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=2e3+3;
vi adj[mxn];
int cnt[mxn], dist[mxn][mxn];
int ptr;

void dfs(int u, int h=0){
	for(int v:adj[u]){
		if(dist[ptr][v]>=h+1){
			dist[v][ptr]=dist[ptr][v]=h+1;
			dfs(v,h+1);
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,x,y;
	cin >> n >> x >> y;
	x--; y--;
	adj[x].eb(y);
	adj[y].eb(x);
	for(int i=0; i<n-1; i++){
		adj[i].eb(i+1);
		adj[i+1].eb(i);
	}
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			dist[i][j]=1e9;
			
	for(int i=0; i<n; i++){
		dist[i][i]=0; ptr=i;
		dfs(i);
	}
	
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			cnt[dist[i][j]]++;
		}
	}
	for(int i=1; i<n; i++)
		cout << cnt[i] << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 16256
import sys

sys.setrecursionlimit(20000)

def search(table, visited, i, j, c):
    visited[i][j] = True

    if table[i+1][j] == c and visited[i+1][j] == False:
        search(table, visited, i+1, j, c)
    if table[i-1][j] == c and visited[i-1][j] == False:
        search(table, visited, i-1, j, c)
    if table[i][j+1] == c and visited[i][j+1] == False:
        search(table, visited, i, j+1, c)
    if table[i][j-1] == c and visited[i][j-1] == False:
        search(table, visited, i, j-1, c)


while True:
    H,W = [int(i) for i in input().split()]
    if H == 0 and W == 0:
        break

    visited = [[False for i in range(W+2)] for j in range(H+2)]
    table = [["." for i in range(W+2)] for j in range(H+2)]

    for i in range(1,H+1):
        s = input()
        for j in range(1,W+1):
            table[i][j] = s[j-1]

    ans = 0
    for i in range(1,H+1):
        for j in range(1,W+1):
            if visited[i][j] == False:
                ans += 1
                search(table, visited, i, j, table[i][j])

    print(ans)



Measured memory_bytes: 15544
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		List<Integer> list = Arrays.asList(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2,
				2, 5, 4, 1, 4, 1, 51);
		Scanner sc = new Scanner(System.in);
		System.out.println(list.get(sc.nextInt() - 1));
	}
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
using i64 = long long;

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

bool rec(std::vector<i64> &v, bool first = true) {
    const i64 sum = std::accumulate(v.begin(), v.end(), 0ll);
    const int n = v.size();
    const int odd = std::count_if(v.begin(), v.end(), [](i64 k) { return k % 2 == 1; });
    if ((sum - n) % 2) return first;
    else if (n == 1 || odd != 1) return !first;

    for (auto &e : v) if (e % 2) {
        if (e == 1) return !first;
        --e;
        break;
    }
    const i64 g = std::accumulate(v.begin(), v.end(), 0ll, gcd);
    for (auto &e : v) e /= g;
    return rec(v, !first);
}

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;
    std::cout << (rec(a) ? "First" : "Second") << std::endl;

    return 0;
}


Measured memory_bytes: 1152
class Integer
  def divisors
    res = []
    kou = []
    r = (self**0.5).floor
    (1...r).each do |i|
      if self % i == 0
        res.push i
        kou.unshift self / i
      end
    end
    res.push r if self % r == 0
    res.concat kou
    block_given? ? res.each{|t| yield t } : res
  end
end

n, m = gets.to_s.split.map{|t| t.to_i }
 
m.divisors.reverse_each do |t|
  if m / t >= n
    puts t
    exit
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 998244353
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 1000005
using namespace std;

ll n,a[Nmax],sp[Nmax],s[Nmax],fr[Nmax],ans2;

template<typename T = long long>
T _pow(T a, T b){
    T ans = 1;
    for (; b; b >>= 1){
        if (b % 2) ans = ans * a % MOD;
        a = a * a % MOD;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i=1;i<=n;i++){
    	cin >> a[i];
    	fr[a[i]]++;
    }
    // for (int i=1;i<=n;i++){
    // 	for (int j=i+1;j<=n;j++){
    // 		ans2 = ans2 + 
    // 	}
    // }
    for (int i=1;i<Nmax;i++){
    	for (int j=i;j<Nmax;j+=i){
    		sp[i] = (sp[i] + fr[j] * j % MOD * j) % MOD;
    		s[i] = (s[i] + fr[j] * j) % MOD;
    	}
    	s[i] = s[i] * s[i] % MOD;
    	s[i] = (s[i] - sp[i] + MOD) % MOD;
    }
    ll ans = 0;
    for (int i=Nmax-1;i>=1;i--){
    	for (int j=i+i;j<Nmax;j+=i){
    		// sp[i] -= sp[j];
    		s[i] = (s[i] - s[j] + MOD) % MOD;
    	}
    	ans = (ans + s[i] * _pow(2LL * i, MOD-2LL)) % MOD;
    }

    cout << ans << '\n';

    return 0;
}

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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            int N = int.Parse(L[0]);
            int M = int.Parse(L[1]);

            int[] AC = new int[N];
            int[] WA = new int[N];

            for(int i=0; i<M; i++)
            {
                S = Console.ReadLine();
                L = S.Split(' ');
                if (L[1] == "AC")
                {
                    AC[int.Parse(L[0]) - 1] = 1;
                }
                else if (L[1] == "WA" && AC[int.Parse(L[0]) - 1] == 0)
                {
                    WA[int.Parse(L[0]) - 1]++;
                }

            }

            int sumAC = 0;
            int sumWA = 0;

            for(int i=0; i<N; i++)
            {
                if(AC[i] == 1)
                {
                    sumAC++;
                    sumWA = sumWA + WA[i]; 
                }
            }

            Console.WriteLine(sumAC + " " + sumWA);
            


        }
    }
}

Measured memory_bytes: 15816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder output = new StringBuilder();

        String input = br.readLine();
        int n = Integer.parseInt(input);
        input = br.readLine();
        String[] strArray = input.split(" ");

        for (int i = (n - 1); i >= 0; i--) {
            int x = Integer.parseInt(strArray[i]);
            output.append(x);
            if(i == 0){
                break;
            }
            output.append(" ");
        }
        output.append("\n");

        try {
            System.out.print(output);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 24324
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll N, M;
    cin >> N >> M;
    vector<int> a(N + 1), b(M + 1);
    set<int> ast, bst;
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
        ast.insert(a[i]);
    }
    for (int j = 1; j <= M; j++)
    {
        cin >> b[j];
        bst.insert(b[j]);
    }
    if (ast.size() != N || bst.size() != M)
    {
        std::cout << 0 << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll res = 1;
    for (int i = N * M; i >= 1; i--)
    {
        int row = -1, col = -1;
        auto itra = lower_bound(a.begin(), a.end(), i);
        auto itrb = lower_bound(b.begin(), b.end(), i);
        row = itra - a.begin();
        col = itrb - b.begin();
        if (ast.find(i) != ast.end() && bst.find(i) != bst.end())
        {
            continue;
        }
        else if (ast.find(i) != ast.end())
        {
            res *= M - col + 1;
            res %= MOD;
        }
        else if (bst.find(i) != bst.end())
        {
            res *= N - row + 1;
            res %= MOD;
        }
        else
        {
            ll tmp = (M - col + 1) * (N - row + 1);
            tmp -= N * M - i;
            res *= tmp;
            res %= MOD;
        }
    }
    std::cout << res << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;



int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) cin >> s[i] >> t[i];
    string x;
    cin >> x;

    bool flag = false;
    int ans = 0;
    rep(i, n){
        if(flag) ans += t[i];
        if(x == s[i]) flag = true;
    }

    cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  int len = s.size();
  ll ans = 0;
  for(int t=0; t<(1<<len-1); t++){
    ll num = s[0]-'0';
    for(int i=0; i<len-1; i++){
      if(t&(1<<i)){
        ans +=num;
        num=0;
      }
      num = num *10 +s[i+1]-'0';
    }
    ans += num;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize
    }
    println!("{}", n * (n-1) / 2);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<assert.h>
#include<sstream>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e18 + 7;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
const int MOD = 21092013;
const double EPS = 1e-8;
//-------------head-------------
int n, a[N];
pii p[N];
int main() {
	scanf("%d", &n);
	rep(i, 0, n)
		scanf("%d", &a[i]), p[i] = mp(a[i], i);
	sort(p, p + n);
	int ans = 0;
	rep(i, 0, n)
		ans += abs(p[i].second - i) & 1;
	printf("%d", ans >> 1);
	return 0;
}


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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
ll _accumulate(const VL &v) { return accumulate(ALL(v), (ll)0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N;
	cin >> N;
	VL A(N);
	REP(i, N) cin >> A[i];

	REP(i, N) {
		if (A[i] == 0) {
			cout << 0 << endl;
			return;
		}
	}

	ll ans = 1;
	REP(i, N) {
		ll ansNext = ans * A[i];
		if (ansNext < ans || 1000000000000000000 < ansNext) {
			ans = -1;
			break;
		}
		ans = ansNext;
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3992
#include<iostream>

#define N_MAX 100001
#define Q_MAX 50000
int count = 0;
int n,q;
int s_array[N_MAX],t_array[Q_MAX];
void down_heap(int array[],int,int);

void printArray(int array[],int n){
    for(int i=1;i<=n;i++){
        std::cout << array[i] << ' ';
    }
    std::cout << '\n';
}

void sort(int array[],int n){
    int length = n;
    for(int i=length/2;i>0;i--){
        down_heap(array,length,i);
    }
    while(length != 1){
        array[0] = array[1];
        array[1] = array[length];
        array[length] = array[0];
        length--;
        for(int i=length/2;i>0;i--){
            down_heap(array,length,i);
        }
    }
}


void down_heap(int array[],int length,int k){
    int child;
    
    while(k <= length/2){
        
        child = 2*k;
        if(child+1 <= length && array[child]<array[child+1]){
            child += 1;
        }
        
        if(array[k] < array[child]){
            array[0] = array[k];
            array[k] = array[child];
            array[child] = array[0];
            k = child;
            
        }else{
            break;
        }
        
    }
}
void search(int k,int left,int right){
    while(left<=right){
        int center = (left+right)/2;
        if(s_array[center] == k){
            count++;
            return;
        }else if(s_array[center]<k){
            left = center+1;
        }else if(s_array[center]>k){
            right = center - 1;
        }
    }
}


int main(){
    int max = 0;
    
    std::cin >> n;
    for(int i=1;i<=n;i++){
        std::cin >> s_array[i];
        if(s_array[i] < max){
            sort(s_array,i);
        }
    }
    //printArray(s_array,n);
    
    //sort(s_array,n);
    
    //printArray(s_array,n);
    
    std::cin >> q;
    for(int i=0;i<q;i++){
        std::cin >> t_array[i];
        search(t_array[i],1,n);
    }
    
    std::cout << count << '\n';
    
    return 0;
}



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

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;
            D = int.Parse(Console.ReadLine());
            if (D == 25)
                Console.WriteLine("Christmas");
            else if (D == 24)
                Console.WriteLine("Christmas Eve");
            else if(D==23)
                Console.WriteLine("Christmas Eve Eve");
            else
                Console.WriteLine("Christmas Eve Eve Eve");
       
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 9044
#include <stdio.h>
#include <string.h>

#define MAX 100

int main(void) {
    char s[MAX];
    char p[MAX];
    char S[MAX*2];

    scanf("%s %s", s, p);

    strcpy(S, s);
    strcat(S, s);

    if(strstr(S, p) == NULL) printf("No\n");
    else printf("Yes\n");

    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m,i,j,k,l;
	cin>>n;
	map<ll,ll > mp;
	ll a[n];REP(i,0,n-1){cin>>a[i];}
	ll dif[n],sum[n];
	REP(i,0,n-1){
		dif[i]=i-a[i];
		sum[i]=a[i]+i;
	}
	REP(i,0,n-1){
		vector<ll> v;
		if(mp.find(sum[i])==mp.end()){
			mp.insert({sum[i],1});
		}
		else{
			mp.find(sum[i])->second++;
		}
	}
	/*REP(i,0,n-1){
		cout<<dif[i]<<" ";
	}*/
	
	ll ans=0;

	REP(i,0,n-1){
		if(mp.find(dif[i])!=mp.end()){
			
			ans+=mp.find(dif[i])->second;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 20740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

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

    int n; cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; ++i) cin >> h[i];

    for(int i=0; i<n; ++i){
        if(i == 0) --h[i];
        else{
            if(h[i-1] < h[i]) --h[i];
            
            if(h[i-1] > h[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
			br.close();
		} catch (IOException e) {
		}

		String[] inputs = input.split(" ");

		int a = Integer.parseInt(inputs[0]);
		int b = Integer.parseInt(inputs[1]);
		int c = Integer.parseInt(inputs[2]);

		if(a > b){
			int tmp = a;
			a = b;
			b = tmp;
		}

		if(b > c){
			int tmp = b;
			b = c;
			c = tmp;
		}

		if(a > b){
			int tmp = a;
			a = b;
			b = tmp;
		}

		System.out.println(a + " " + b + " " + c);
	}
}


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

const int maxN = 100005;
const int oo=1e9+7;
int dp[maxN][4];
int a[maxN][4];
int n;

int main()
{
    //freopen("Vacation.inp","r",stdin);
    //freopen("Vacation.out","w",stdout);

    cin >> n;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=3; j++){
            cin >> a[i][j];
            dp[i][j]=-oo;
        }

    for (int j=1; j<=3; j++)
        dp[0][j]=0;

    //Tinh bang phuong an dp[i][j]
    for (int i=1; i<=n; i++){
        for (int j=1; j<=3; j++){
            if (j==1)
                dp[i][j]=max(a[i][j]+dp[i-1][2], a[i][j]+dp[i-1][3]);
            if (j==2)
                dp[i][j]=max(a[i][j]+dp[i-1][1], a[i][j]+dp[i-1][3]);
            if (j==3)
                dp[i][j]=max(a[i][j]+dp[i-1][2], a[i][j]+dp[i-1][1]);
        }
    }
    cout << max(dp[n][1],max(dp[n][2],dp[n][3]));
    return 0;
}


Measured memory_bytes: 6732
#include<stdio.h>
int main(void)
{
	int x1,y1,x2,y2,a,b,x3,y3,x4,y4;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	a=x1-x2;
	b=y1-y2;
	a*=-1;
	b*=-1;
	x3=x2-b;
	y3=y2+a;
	x4=x3-a;
	y4=y3-b;
	printf("%d %d %d %d\n",x3,y3,x4,y4);
	return 0;
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)

//MIN-MAX
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll solve(vector<ll>vect,ll n)
{
   vector<ll>dp(n,0);
   dp[0]=0;
   dp[1]=abs(vect[0]-vect[1]);

   for(int i=2;i<n;i++)
   {

       dp[i]=min(abs(vect[i-2]-vect[i])+dp[i-2],abs(vect[i-1]-vect[i])+dp[i-1]);


   }

    return dp[n-1];

}


int main()
{
	FASTIO;
	ll n;
	 cin>>n;
	 vector<ll>vect(n);
	 f(i,0,n)
        cin>>vect[i];

    ll ans=solve(vect,n);
    cout<<ans<<"\n";

	return 0;
}













Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll a[55];
ll cnt;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    while(1)
    {
        ll mx = -1, mi = 0;
        for(ll i = 0; i < n; i++)
        {
            if(a[i] >= mx) mx = a[i], mi = i;
        }
        ll t = a[mi] / n;
        if(t == 0) break;
        a[mi] %= n;
        for(ll i = 0; i < n; i++)
        {
            if(i == mi) continue;
            a[i] += t;
        }
        cnt += t;
    }
    cout<<cnt<<endl;
    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 pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n; cin >> n;
  set<string> st;
  rep(i,n){
      string s;
      cin >> s;
      st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 19228
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, x; cin >> a >> b >> x;
    a += x, b += x;

    cout << b / x - (a - 1) / x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int indexN=-1,indexW=-1,indexE=-1,indexS=-1;
    for(int i = 0; i < s.length(); i++){
        if(s[i]=='N')indexN=i+1;
        if(s[i]=='W')indexW=i+1;
        if(s[i]=='S')indexS=i+1;
        if(s[i]=='E')indexE=i+1;
    }
    if(indexN*indexS<0){
        cout << "No" << endl;
        return 0;
    }
    if(indexW*indexE<0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    string str;
    getline(cin,str);
    rep(i,n){
        getline(cin,str);
        int k = str.size();
        rep(j,k){
            if(str[ j ] == 'H' && j+1 < k){
            if(str[j+1] == 'o' && j+2 < k){
            if(str[j+2] == 's' && j+3 < k){
            if(str[j+3] == 'h' && j+4 < k){
            if(str[j+4] == 'i' && j+5 < k){
            if(str[j+5] == 'n' && j+6 < k){
            if(str[j+6] == 'o'){ 
                str[j+6] = 'a'; 
            }}}}}}}
        }
        cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  if (b > a) {
    auto tmp = a;
    a = b;
    b = tmp;
  }  // post: a >= b
  while(b!=0) {
    auto tmp = a % b;
    a = b;
    b = tmp;
  }
  cout << a << endl;
}


Measured memory_bytes: 3108
N=int(input())
a=list(map(int,input().split()))
res=set()
free=0
for i in range(len(a)):
  if a[i]<400:
    res.add("gray")
  elif a[i]<800:
    res.add("brown")
  elif a[i]<1200:
    res.add("green")
  elif a[i]<1600:
    res.add("water")
  elif a[i]<2000:
    res.add("blue")
  elif a[i]<2400:
    res.add("yellow")
  elif a[i]<2800:
    res.add("orange")
  elif a[i]<3200:
    res.add("red")
  else:
    free+=1

col=len(res)
print(col if col>0 else 1,col+free)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int N,M,X;
    cin>>N>>M>>X;
    int a[M];
    for(int i=0;i<M;i++){
        cin>>a[i];
        
    }
    int r=0,l=0;
    for(int i=0;i<M;i++){
        if(a[i]<X){
            l+=1;
        }else{
            r+=1;
        }
    }
   if(r<l){
       cout<<r<<endl;
   }else{
       cout<<l<<endl;
   }
    
    
    return 0;
}


Measured memory_bytes: 256
n=int(input())
n+=1
p=[0]*n
a=[0]*n
b=[0]*n
for i in range(1, n):
    p[i],a[p[i]]=map(int,input().split())
m=n+1
c=0
for i in range(1,n):
    m=min(m,a[i])
    if n-i==m:
        d=i-c
        while c<i:
            c+=1
            b[c]=d
for i in range(1,n):
    print(b[p[i]])

Measured memory_bytes: 78728