akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 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;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
 ios::sync_with_stdio(false);

ll x,n;
cin>>x>>n;
ll p[n+1];
rep(i,n){
	cin>>p[i];
}

ll num[200];
for(int i=0;i<=199;i++){
	num[i]=0;
}
rep(i,n){
	num[p[i]]++;
}

ll dis=0;
while(true){
if(num[x-dis]==0){
	cout<<x-dis<<endl;
	return 0;
}
if(num[x+dis]==0){
	cout<<x+dis<<endl;
	return 0;
}
dis++;

}




return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
 int a,b,c,d;
 cin>>a>>b>>c>>d;
 if(b>=0 && d>=0)
 {
 int k=max(a*c,b*d);
 cout<<k<<endl;
 }
 else if(b<0 && d<0)
 cout<<a*c<<endl;
 else if(b<0)
 {
    if(c<0)
    cout<<a*c<<endl;
    else
    cout<<b*c<<endl;
 }
 else
 {
    if(a<0)
    cout<<a*c<<endl;
    else
    cout<<a*d<<endl;
 }
}


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

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

	int N; cin >> N;
	long long a[2100], c;
	long long K; cin >> K;
	long long ans = 0, cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		long long z = 0;
		for (int j = 0; j < i; j++) {
			if (a[j] > a[i]) {
				z++;
			}
		}
		c = 0;
		for (int j = i + 1; j < N; j++) {
			if (a[j] > a[i]) {
				c++;
			}
		}
		cnt += c + z;
		ans -= c;
	}
	ans = ans * K % 1000000007;
	K = (K + 1) * K / 2 % 1000000007;
	ans += cnt * K;
	ans %= 1000000007;
	if (ans < 0)ans = 1000000007 + ans;
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long cc;
const int N = 1000005;
cc n, a[N];
cc val(int l, int h) {
    return 1ll * (cc(h) * cc(h + 1) >> 1) - 1ll * (cc(l - 1) * cc(l) >> 1);
}
cc sum;
int main() {
    ios_base :: sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum % val(1, n)) {
        cout << "NO";
        return 0;
    }
    cc K = sum / val(1, n);
    for (int i = 0; i < n; i++) {
        cc dif = a[i] - a[(i + 1) % n] + K;
        if (dif < 0 || dif % n) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 1024
//ABC073B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	int sigma = 0;
	for(int i=0;i<n;i++){
		int l, r;
		cin >> l >> r;
		sigma += r-l+1;
	}
	cout << sigma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vpair e[100005];
vint c;

void dfs(int v, int num) {
    int count = 1;
    for (auto x : e[v]) {
        if (count == num) count++;
        if (c[x.se] == 0) {
            c[x.se] = count;
            dfs(x.fi, count);
            count++;
        }
    }
}

int main() {
    int n;
    cin >> n;
    c.resize(n-1, 0);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        e[a].emplace_back(b, i);
        e[b].emplace_back(a, i);
    }
    dfs(0, 0);

    cout << vmax(c) << endl;
    rep(i, n-1) cout << c[i] << endl;
    return 0;
}

Measured memory_bytes: 7424
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
Shining through the city with a little funk and soul
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
         {
            st = new StringTokenizer(infile.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            arr[i] = a^b;
         }
         String res = "No";
         for(int i=0; i < N-2; i++)
            if(arr[i]+arr[i+1]+arr[i+2] == 0)
               res = "Yes";
         System.out.println(res);
      }
   }

Measured memory_bytes: 32700
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define MOD 1000000007
 
int main(){
    string S, T; cin >> S >> T;
    int cnt = 0;
    rep(i,3){
        if(S[i] == T[i]) cnt++;
    }
    cout << cnt;
}


Measured memory_bytes: 256
import collections
S =  input()
c=collections.Counter(S)

A = dict(c)
B = list(A.keys())

if (len(B) != 2):
    print('No')
    
else:
    if ((A[B[0]] == 2)and(A[B[1]] == 2)):
        print('Yes')
    else:
        print("No")

Measured memory_bytes: 3316
N_M = list(map(int,input().split()))
N = N_M[0]
M = N_M[1]
a = [input().split() for l in range(M)]
ans = 0
d = [0, 0, 0]
f1, f2, f3 = 0, 0, 0

for i in range(M):
    if N == 1:
        if a[i][0] == '1':
            
            if f1 == 0:
                f1 = 1
                t1 = int(a[i][1])
                ans = int(a[i][1])
            elif t1 != int(a[i][1]):
                ans = -1
                break
    if N == 2:
        if a[i][0] == '1':
            if a[i][1] == '0':
                ans = -1
                break
            
            if f1 == 0:
                f1 = 1
                t1 = int(a[i][1])
                ans = ans + 10 * int(a[i][1])
            elif t1 != int(a[i][1]):
                ans = -1
                break
        elif a[i][0] == '2':
            
            if f2 == 0:
                f2 = 1
                t2 = int(a[i][1])
                ans = ans + int(a[i][1])
            elif t2 != int(a[i][1]):
                ans = -1
                break
    if N == 3:
        if a[i][0] == '1':
            if a[i][1] == '0':
                ans = -1
                break
            if f1 == 0:
                f1 = 1
                t1 = int(a[i][1])
                ans = ans + 100 * int(a[i][1])
            elif t1 != int(a[i][1]):
                ans = -1
                break
        elif a[i][0] == '2':
            
            if f2 == 0:
                f2 = 1
                t2 = int(a[i][1])
                ans = ans + 10 * int(a[i][1])
            elif t2 != int(a[i][1]):
                ans = -1
                break
        elif a[i][0] == '3':
            
            if f3 == 0:
                f3 = 1
                t3 = int(a[i][1])
                ans = ans + int(a[i][1])
            elif t3 != int(a[i][1]):
                ans = -1
                break
if len(str(ans)) < N and ans != -1:
    ans = ans + 10 ** (N-1)
print(ans)

Measured memory_bytes: 3192
N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 1000000007
ans = 0
list = [[0,0] for i in range(N)]
I = 0
J = 0
for i in range(N):
  for j in range(i):
    if A[j] < A[i]:
      list[i][0] += 1
      I += 1
      J += 1
  for k in range(i+1,N):
    if A[k] < A[i]:
      list[i][1] += 1
      J += 1
#print(list)
for i in range(N):
  ans += int(K*list[i][1] + K*(K-1)*(list[i][0]+list[i][1])//2)                      
print(ans%mod)
                          
                          
                          
                          
                          
                          
                          
         


Measured memory_bytes: 9308
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi l(n);
  int sum = 0;
  int maxl = 0;
  rep(i, n){
    cin >> l[i];
    sum += l[i];
    chmax(maxl,l[i]);
  }
  if(maxl < sum - maxl) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int p;
    cin>>s;
    int n=s.length();
    if(s[n-1]=='s')
    {
    s=s+"es";
        
    }
    else
    {
        s=s+"s";
    }
    cout<<s;
}

Measured memory_bytes: 3596
from itertools import accumulate
import math
m = 10**5

L = [x for x in range(2,m+1)]

#エラトステネスのふるいで素数を抽出
for y in range(2, int(math.sqrt(m)+1)):
    L = [z for z in L if(z == y or z % y != 0)]

#N+1/2も素数であるものを抽出
P = []
for w in L:
    if (w+1)/2 in L:
        P.append(w)

#累積和のために作成
G = [0] * (m+1)
for i in P:
    G[i+1] = 1

#累積和
Q = list(accumulate(G))



n = int(input())
for _ in range(n):
    s, t = map(int, input().split())
    print(Q[t+1]-Q[s])




'''
この素数判定は遅い。
上のようにエラトステネスの篩を使う

def isPrime(n):

    if n == 1:
        return False
    if n % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(n)+1), 2):
        if n % i == 0:
            return False
    return True

'''


Measured memory_bytes: 85588
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
  
int n, m;
double grow[100][100];
double dp[110][110];
  
int main() {
    while(std::cin >> n >> m, n + m) {
      
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            std::cin >> grow[i][j];
        }
    }
  
    for(int i = 0; i < n; ++i) {
        dp[0][i] = 1.;
    }
    for(int i = 1; i < m; ++i) {
        for(int j = 0; j < n; ++j) {
            dp[i][j] = 0.;
        }
    }
  
    for(int i = 1; i < m; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < n; ++k) {
                dp[i][j] = std::max(dp[i][j], dp[i - 1][k] * grow[k][j]);
            }
        }
    }
  
    printf("%.2lf\n", ((long long)(*std::max_element(dp[m - 1], dp[m - 1] + n) * 100 + 0.5)) / 100.);
  
  
    }
}

Measured memory_bytes: 1412
<?php
$n=(int)trim(fgets(STDIN));
$o='';
for($i=1;$i<=$n;$i++){
  if($i%3==0) $o.=' '.$i;
  else{
   $x=$i;
   while($x){
      if($x%10==3){
        $o.=' '.$i;
        break;
      }
      $x=floor($x/10);
    }
  }
}
print $o;
?>

Measured memory_bytes: 15432
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    ll N, K;
    cin >> N >> K;
  
    double ans = 0;
    for (double i=1; i<=N; ++i) {
        double choice = 1.0 / N;
        double num = i;
        double win = 1;
        while (num < K) {
            num = num * 2;
            win = win / 2;
        }
        ans += choice * win;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    ll k,x;
    cin>>k>>x;
    k*=500;
    if(k>=x) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] A = new Integer[N];
        Integer[] B = new Integer[N];
        Integer[] C = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = scan.nextInt();
        }
        for (int i = 0; i < N; i++) {
            C[i] = scan.nextInt();
        }
        Arrays.sort(A);
        Arrays.sort(C);
        long answer = 0;
        for (int i = 0; i < N; i++) {
            long top = ~Arrays.binarySearch(A, B[i], (x,y)->x.compareTo(y)>=0?1:-1);
            long bottom = ~Arrays.binarySearch(C, B[i], (x,y)->x.compareTo(y)>0?1:-1);
            answer += top * (N - bottom);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 102696
import sys
input = sys.stdin.readline

W, H, N = map(int, input().split(' '))
field = [[0 for _ in range(W)] for _ in range(H)]
for _ in range(N):
    x, y, a = map(int, input().split(' '))
    if a == 1:
        for i in range(H):
            for j in range(x):
                field[i][j] = 1
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                field[i][j] = 1
    elif a == 3:
        for i in range(y):
            field[i] = [1] * (W)
    elif a == 4:
        for i in range(y, H):
            field[i] = [1] * (W)
ans = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, x: "List[int]"):
    ret = float('inf')
    for i in range(K - 1, N):
        l = x[i - (K - 1)]
        r = x[i]
        if l < 0 and r > 0:
            tmp = min(abs(l) * 2 + r, abs(l) + r * 2)
            ret = min(ret, tmp)
        else:
            ret = min(ret, max(abs(r), abs(l)))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, x)

if __name__ == '__main__':
    main()


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

import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)

from collections import Counter
from math import factorial

def nCr(n, r):
    # 10C7 = 10C3
    r = min(r, n-r)
    return factorial(n) / factorial(r) / factorial(n-r)

round = lambda x: int((x*2+1) // 2)

N, A, B = map(int, input().split())
vN = list(map(int, input().split()))

# 組み合わせ計算用に、各値の個数も出しておく
c = Counter(vN)
# 大きい値が欲しいので降順ソートしておく
vN.sort(reverse=True)

mx_avg = sum(vN[:A]) / A
lists = [vN[:A]]
for i in range(A+1, B+1):
    avg = sum(vN[:i]) / i
    if avg == mx_avg:
        # 平均値が最大になるなら、選び方リストに追加
        lists.append(vN[:i])

ans = 0
for l in lists:
    # 選び方を、同じ値の個数毎にまとめる
    c2 = Counter(l)
    combs = 1
    for k, v in c2.items():
        # 同じ値が複数ある場合の組み合わせを出す
        combs *= nCr(c[k], v)
    ans += combs
print(mx_avg)
print(round(ans))


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

void PrintfArray(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        if( i )
            cout << " ";
        cout << a[i];
    }
    cout << endl;
}

int selectionSort(int a[], int n)
{
    int count = 0;
    for(int i=0; i<n-1; i++)
    {
        int index = i;
        for(int j=i+1; j<n; j++)
        {
            if(a[j] < a[index])
                index = j;
        }
        if(index != i){
            count++;
            a[i] += a[index];
            a[index] = a[i] - a[index];
            a[i] = a[i] - a[index];
        }
    }
    return count;
}

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for(int i = 0; i < n; i++)
	{
	    cin >> a[i];
	}
	int sw = selectionSort(a, n);
	PrintfArray(a, n);
	cout << sw << endl;
	
	return 0;
}

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int K; cin >> K;
    string s; cin >> s;
    if(s.length() <= K) cout << s << endl;
    else cout << s.substr(0, K) << "..." << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13
 
using namespace std;
 
int array[128];
 
int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}
 
int main(){
 
    array['A']=1,array['C']=2,array['G']=3,array['T']=4;
 
    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];
 
    char* check_table = new char[TABLE_SIZE];
 
    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}


Measured memory_bytes: 4520
H,W=map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(H)]
B = [[int(a) for a in input().split()] for _ in range(H)]
C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
X = [[0] * (W) for _ in range(H)]

ofs=80*(H+W)

X[0][0]=1<<(ofs+C[0][0])|1<<(ofs-C[0][0])
for i in range(H):
    for j in range(W):
        if i>0:
            X[i][j]|=(X[i-1][j]<<C[i][j]|X[i-1][j]>>C[i][j])
        if j>0:
            X[i][j]|=(X[i][j-1]<<C[i][j]|X[i][j-1]>>C[i][j])

for k in range(ofs):
    if (X[i][j]>>(k+ofs)&1):
        break
print(k)

Measured memory_bytes: 58204
n = int(input())
n_list = list(map(int,input().split()))
q = int(input())
q_list = list(map(int,input().split()))

from functools import lru_cache

@lru_cache(10000)
def solve(i, m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = (solve(i+1, m) | solve(i+1, m-n_list[i]))
    return res


for m in q_list:
    if solve(0, m):
        print('yes')
    else:
        print('no')


Measured memory_bytes: 11632
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<vector<pair<int,bool>>> xy(N);
  REP(i,N){
    int A;cin>>A;
    REP(j,A){
      int x,y;
      cin>>x>>y;
      x--;
      xy[i].emplace_back(x,y);
    }
  }
  int ans=0;
  for(int bit=0;bit<(1<<N);++bit){
    vector<int> S;
    bool flag=true;
    int cnt=0;
    vector<bool> honest(N);
    REP(i,N){
      if(bit&(1<<i))honest[i]=true;
    }
    REP(i,N){
      if(honest[i]){
        cnt++;
        for(auto p:xy[i]){
          if(honest[p.first]!=p.second){
            flag=false;
          };
        }
      }
    }

    if(flag)ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let (mut a, mut b, mut c): (isize, isize, isize) = (io.read(), io.read(), io.read());

    let mut ans;
    if a & 1 == 0 || b & 1 == 0 || c & 1 == 0 {
        ans = 0;
    } else {
        ans = min(a * b, min(b * c, c * a));
    }
    io.writeln(ans);
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol a, b, c; cin >> a >> b >> c;
    if((a == b && a != c) || (c == b && a != c) || (a == c && a != b))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3548
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		int n = Integer.parseInt(br.readLine());
		List<Integer> aList = Arrays.asList(br.readLine().split(" ")).stream()
				.map(Integer::parseInt)
				.collect(Collectors.toList());
		int q = Integer.parseInt(br.readLine());
		List<Integer> mList = Arrays.asList(br.readLine().split(" ")).stream()
				.map(Integer::parseInt)
				.collect(Collectors.toList());
		for(int m: mList){
			if(solve(aList, 0, m)){
				System.out.println("yes");
			}else{
				System.out.println("no");
			}
		}
	}
	
	public static boolean solve(List<Integer> list, int startIndex, int m){
		if(m == 0){
			return true;
		}
		if(list.size() <= startIndex){
			return false;
		}
		return solve(list, startIndex + 1, m) || solve(list, startIndex + 1, m - list.get(startIndex));
	}
}


Measured memory_bytes: 31568
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}


void solve(long long K){
  ll ans = 0;
  for(ll a=1; a<=K; a++){
    for(ll b=1; b<=K; b++) {
      for(ll c=1; c<=K; c++) {
	ans +=gcd(a, gcd(b, c));
      }
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long K;
  scanf("%lld",&K);
  solve(K);
  return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#define int long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define rc(s) return cout<<s,0
using namespace std;

int a,b;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    cin >> a >> b;
    cout<<max(2*a-1,max(2*b-1,a+b));

}

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

typedef std::pair<std::string, int> PAIR;
bool cmp(const PAIR &a, const PAIR &b)
{
    if (a.second > b.second)
    {
        return true;
    }
    if (a.second < b.second)
    {
        return false;
    }
    return a.first < b.first;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

    std::map<std::string, int> m;
    std::string s;
    int n;

    std::cin >> n;
    while (n--)
    {
        std::cin >> s;
        m[s]++;
    }

    std::vector<PAIR> vec(m.begin(), m.end());
    std::sort(vec.begin(), vec.end(), cmp);
    n = vec[0].second;
    std::cout << vec[0].first << "\n";
    for (int i = 1; i < vec.size(); i++)
    {
        if (vec[i].second < n)
            break;
        std::cout << vec[i].first << "\n";
    }

    return 0;
}

Measured memory_bytes: 27008
from functools import reduce
from itertools import combinations
from operator import mul


def solve(string):
    n, *s = string.split()
    num = [len([True for _s in s if _s[0] == _i]) for _i in "M A R C H".split()]
    ans = 0
    for n in combinations(num, 3):
        ans += reduce(mul, n)
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


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

using namespace std;
using ll = long long;

const int maxn = 111111;
ll dp[maxn];

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, full; cin >> n >> full;
    for (int i = 0; i < maxn; i++) dp[i] = INT_MAX;
    dp[0]=0;
    for (int i = 0; i < n; i++) {
        int w, value; cin>>w>>value;
        for(int x=maxn-1;x>=value;x--){
            dp[x] = min(dp[x], dp[x-value]+w);
        }
    }
    for (int i = maxn-1;i>=1;i--) {
        if (dp[i]<=full) {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 1152
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    F0R(i,3)
        cout << s[i];

    return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n;
	cin >> n;
	
	vi v(1e5+15 , 0);
	rep(i , n){
		int x;
		cin >> x;
		++x;
		++v[x];
		++v[x + 1];
		++v[x - 1];
	}
	
	int ans = 0;
	
	rep(i , sz(v)){
		if(v[ans] <= v[i]){
			ans = i;
		}
	}
	
	cout << v[ans];
	
	return 0;
}

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

using namespace std;

using ll = long long;

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

    ll S; cin >> S;
    ll a = (ll)ceil(sqrt((double)S));
    ll b = a * a - S;
    cout << "0 0 " << a << " " << b << " 1 " << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int H,W;
  while(cin>>H>>W){
    if(H==0) break;
    vector<string> grid(H);
    int sum[501][501] = {0};
    REP(i,H){
      cin>>grid[i];
    }
    REP(y,H)REP(x,W){
      sum[y+1][x+1] = sum[y+1][x] + sum[y][x+1] - sum[y][x];
      sum[y+1][x+1] += (grid[y][x]=='*')?1:0;
    }
    int ans=0;
    /*
    REP(y1,H)REP(x1,W)FOR(y2,y1+1,H)FOR(x2,x1+1,W){
      if(sum[x2+1][y2+1]-sum[x1][y2+1]
          -sum[x2+1][y1]+sum[x1][y1]==0){
        ans = max((x2-x1+1)*(y2-y1+1),ans);
      }
    }
    */
    bool f = false;
    FOR(dy,1,H+1){
      FOR(dx,1,W+1){
        f = false;
        FOR(y,dy-1,H){
          FOR(x,dx-1,W){
            if(sum[y+1][x+1]-sum[y+1-dy][x+1]
                -sum[y+1][x+1-dx] + sum[y+1-dy][x+1-dx]==0){
              f = true;
              break;
            }
          }
          if(f) break;
        }
        if(f) ans = max(ans,dx*dy);
        else break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

constexpr int MAX_N = 8;

int N, A[3];
int l[MAX_N];

int dfs(int n, array<int, 3> a, int mp) {
  if (n == N) {
    for (int i{}; i < 3; ++i) {
      if (a[i] == 0) {
        return numeric_limits<int>::max();
      }
      mp += abs(A[i] - a[i]);
    }
    return mp;
  }

  int ret[4];
  for (int i{}; i < 3; ++i) {
    array<int, 3> na{a};
    int nmp{mp};
    if (na[i] > 0) {
      nmp += 10;
    }
    na[i] += l[n];
    ret[i] = dfs(n + 1, na, nmp);
  }
  ret[3] = dfs(n + 1, a, mp);
  sort(ret, ret + 4);

  return ret[0];
}

int main() {
  cin >> N;
  for (int i{}; i < 3; ++i)
    cin >> A[i];
  for (int i{}; i < N; ++i)
    cin >> l[i];

  array<int, 3> a{};
  cout << dfs(0, a, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
list=[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]
n=int(input())
print(list[n-1])

Measured memory_bytes: 3060
n = int(input())
input_line = input().split()
member = [int(input_line[i]) for i in range(n)]

stands = 0
for i in range(1,n): 
  stand = member[i-1] - member[i]
  if stand > 0:
    stands += stand
    member[i] += stand
print(stands)

Measured memory_bytes: 105056
#include <cstdio>
#include <set>

using namespace std;

int main(){
  int a[100000],n,m;

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

  set<int> st;
  int cnt = 0;
  for(int i = n-1 ; i >= 0 ; i--){
    if(cnt == m) break;
    if(!st.count(a[i])){
      cnt++;
      st.insert(a[i]);
      printf("%d\n" ,a[i]);
    }
  }

  return 0;
}

Measured memory_bytes: 3928
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int p = 1000000007;
#define vel vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	string s; cin >> s;
	int n = s.size();
	vector<vel> lis(3);
	vel sum(n + 1);
	bool fl = true;
	rep(i, n) {
		lis[sum[i]].push_back(i);
		sum[i + 1] = sum[i] + (s[i] - 'a') + 1; sum[i + 1] %= 3;
		if (i % 2 == 0 xor s[i] == s[0]) { fl = false; }
	}
	if (fl) { cout << 1 << endl; return 0; }
	vel dp(n);
	dp[0] = 1;
	int ans = 0;
	rep(i, n) {
		if (sum[i] != sum[n]) { ans += dp[i]; ans %= p; }
		int pla = (sum[i] + 1) % 3;
		auto itr = lower_bound(lis[pla].begin(), lis[pla].end(), i);
		if (itr != lis[pla].end()) { dp[*itr] += dp[i]; dp[*itr] %= p; }
		pla++; pla %= 3;
		itr = lower_bound(lis[pla].begin(), lis[pla].end(), i);
		if (itr != lis[pla].end()) { dp[*itr] += dp[i]; dp[*itr] %= p; }
	}
	cout << ans % p << endl;
}


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

public class MainClarss
{
	public const long Giri = 1000000007;
	private static long r;
	private static void KillImpl(long[] a, Hero h, int target)
	{
		if(a[target]==0)
			return;
		
		if(h.AP == 0)
			return;
			
		if(h.AP-a[target]<0)
		{
			a[target]-=h.AP;
			r+=h.AP;
			//Console.WriteLine(h.ID+":+"+h.AP);
			h.AP=0;
		}
		else
		{
			h.AP-=a[target];
			r+=a[target];
			//Console.WriteLine(h.ID+":+"+a[target]);
			a[target]=0;
		}
	}
	
	private static void KillMax(long[] a, Hero h, int before, int next)
	{
		if(a[before] == 0)
		{
			KillImpl(a, h, next);
			return;
		}
		
		if(a[next] == 0)
		{
			KillImpl(a, h, before);
			return;
		}
		
		if(a[before] > a[before])
		{
			KillImpl(a, h, before);
		}
		else
		{
			KillImpl(a, h, next);
		}

	}
	
	private static void KillMin(long[] a, Hero h, int before, int next)
	{
		if(a[before] == 0)
		{
			KillImpl(a, h, next);
			return;
		}
		
		if(a[next]==0)
		{
			KillImpl(a, h, before);
			return;
		}
		
		if(h.ID-1<0)//左端
		{
			KillImpl(a,h,before);
			return;
		}
		
		if(h.ID+1>=a.Length)//右端
		{
			KillImpl(a,h,next);
			return;
		}
		
		long mae = a[h.ID-1];
		long usiro = a[h.ID+1];
		
		if(mae==usiro)
		{
			if(a[before] < a[before])
		{
			KillImpl(a, h, before);
		}
		else
		{
			KillImpl(a, h, next);
		}
		return;
		}
		if(mae>usiro)
		{
			KillImpl(a,h,next);
		}
		else
		{
			KillImpl(a,h,before);
		}
		
	}
	
	public static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] io = Input();
		long[] a = new long[n+1];
		long[] a2 = new long[n+1];
		List<Hero> heros = new List<Hero>(n);
		List<Hero> heros2 = new List<Hero>(n);
		
		for(int i = 0; i < n+1; i++)
		{
			a[i] = long.Parse(io[i]);
			a2[i] = long.Parse(io[i]);
		}
		io = Input();
		for(int i = 0; i < n; i++)
		{
			long ap = long.Parse(io[i]);
			heros.Add(new Hero(){ ID=i, AP=ap});
			heros2.Add(new Hero(){ ID=i, AP=ap});
		}
		
		//heros.Sort((_a,b)=>(int)(b.AP-_a.AP));
		
		r = 0;
		for(int i = 0; i < n;i++)
		{
			Hero h = heros[i];
			int bf = h.ID;
			int ne = h.ID+1;
			
			//11kaime
			//tiisaihou
			/*
			KillMin(a, h, bf, ne);

			if(h.AP > 0)
			{
				KillMax(a, h, bf, ne);
			}
			*/
			
			KillImpl(a, h, bf);
			KillImpl(a, h, ne);
			
		}
		long maeR = r;
		for(int i = n-1; i >= 0;i--)
		{
			Hero h = heros[i];
			int bf = h.ID;
			int ne = h.ID+1;
			
			//11kaime
			//tiisaihou
			/*
			KillMin(a, h, bf, ne);

			if(h.AP > 0)
			{
				KillMax(a, h, bf, ne);
			}
			*/
			
			KillImpl(a, h, bf);
			KillImpl(a, h, ne);
			
		}
		
		
		Console.WriteLine(Math.Max(maeR,r));
	}
	
	class Hero
	{
		public int ID{get;set;}
		public long AP{get;set;}
	}
	
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 41448
#include<iostream>

using namespace std;

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

  if (s == 1 || s == 2) {
    cout << 4 << endl;
    return 0;
  }

  int n = 1000000;
  int seq[n];
  int x;
  bool isFirst = true;

  seq[0] = s;
  for (int i = 1; i < n; i++) {
    int item = seq[i - 1];
    // cout << item << endl;
    if (item == 4 && isFirst) {
      isFirst = false;
    }
    else if (item == 4 && !isFirst) {
      x = i - 1;
      break;
    }

    if (item % 2 == 0) {
      seq[i] = item / 2;
    }
    else {
      seq[i] = item * 3 + 1;
    }
  }

  cout << x + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define rp(i,l,m) for(int i=l; i<m; ++i)
#define Rp(i,l,m) for(int i=l; i<=m; i++)
#define rpD(i,l,m) for(int i=m; i>l; i--)
#define RpD(i,m,l) for(int i=m; i>=l; i--)
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define sz(a) int((a).size())
#define is insert
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = (int) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a, ll b) {ll r; while (b) {r=a%b;a=b;b=r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p=MOD){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%p;n=n*n%p;}return r;}
#define N 200005

int a[N], ans,n;

inline void Init(){
    cin >> n;
    rp(i,0,n) cin >> a[i];


}
// 6 12 18 28 36 54 64

inline void solve(){
    if(n==2) cout << max(a[0],a[1]), exit(0);
    ans=max(max(gcd(a[0],a[1]), gcd(a[1],a[2])), gcd(a[0],a[2]));
    int l=0; int r=n;
    while(l<r){
        int x=gcd(ans,a[l]);
        int y=gcd(ans,a[r]);
        if(x>y) ans=x, l++; else ans=y, r--;
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    Init();
    solve();
  return 0;
}


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

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

    if(n <= 6){
        cout << 1 << endl;
        return 0;
    }
    else if(n <= 11){
        cout << 2 << endl;
        return 0;
    }
    
    ll m = n % 11;
    ll d = n / 11;
    if(m == 0) cout << 2*d << endl;
    else if(m <= 6) cout << 2*d + 1 << endl;
    else cout << 2*d + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 555;

char ss[N];
char s[N][N];

void fill(int n, int m, int d, int x, int y, char c) {
	//if (x>=0 && y>=0 && x<n && y<m) s[x][y]=c;
	//return;
	for (int i=1-d; i<d; i++) {
		int lo = 1-d+abs(i), hi = d-abs(i);
		for (int j = lo; j <= hi; j++) if (x+i>=0 && x+i<n && y+j>=0 && y+j<m) s[x+i][y+j]=c;
	}
}

int main() {
	int n,m,d;
	scanf("%d%d%d", &n, &m, &d);
	if (d%2==1) {
		FOR(i,n) {
			FOR(j,m) ss[j] = "RY"[(i+j)%2];
			printf("%s\n", ss);
		}
		return 0;
	}
	d /= 2;
	FOR(i,n) FOR(j,m) s[i][j]=' ';
	for (int I = -2*d; I < n+2*d; I += 2*d) for (int J = -4*d; J < m+4*d; J += 4*d) {
		int ff=I/(2*d)%2;
		fill(n,m,d,I,J,"RY"[ff]);
		fill(n,m,d,I+d,J+d,"GB"[ff]);
		fill(n,m,d,I,J+2*d,"YR"[ff]);
		fill(n,m,d,I+d,J+3*d,"BG"[ff]);
	}
	FOR(i,n) {
		printf("%s\n", s[i]);
	}
	return 0;
}


Measured memory_bytes: 768
import java.io.*;
import java.util.*;

class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        StringBuilder sb = new StringBuilder();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(b-a == c-b ? "YES" : "NO");
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 23380