akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+4;
const int INF = 1e8+54;
int n;
int a[2*N];
int b[2*N];
bool check(int val)
{
	int pos1 = INF,pos2 = -INF;
	for(int i=1;i<=2*n-1;i++)
	{
		b[i] = (a[i] >= val);
//		cout<<b[i]<<" ";
	}
//	cout<<"\n";
	for(int i=n;i<=2*n-1;i++)
	{
		if(b[i] == b[i+1])
		{
			pos1 = i;
			break;
		}	
	}
	
	for(int i=n;i>=1;i--)
	{
		if(b[i] == b[i-1])
		{
			pos2 = i;
			break;
		}
	}
	
	if(pos1 == INF && pos2 == -INF)
	{
		if(n % 2 != 0)
			return b[n];
			
		else
			return (b[n] ^ 1);
	}
			
	if(pos1-n+1 < n-pos2+1)
		return b[pos1];
		
	else
		return b[pos2];
	
}

int main()
{
	cin>>n;
	for(int i=1;i<=2*n-1;i++)
	{
		scanf("%d",&a[i]);
	}
	
	int l=1,r=2*n-1;
	while(l < r)
	{
		int mid = (l+r+1)/2;
//		cout<<mid<<"\n";
		if(check(mid) == 1) l = mid;
		else r = mid-1; 
	}
	
	cout<<l;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
long long n,m,sum;
long long ksm(long long x,long long n)
{
  long long Ans=1;
  for(;n;n>>=1,x=x*x)
      if(n&1) Ans=Ans*x;
  return Ans;
}
int main()
{
  scanf("%lld",&n);
  for (int i=1;i<=n;i++)
  {
    scanf("%lld",&m);
    if (m%2==0)sum++;
  }
  printf("%lld\n",ksm(3,n)-ksm(2,sum));
  return 0;
}


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

int main()
{
    int N;

    cin >> N;

    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if (i * j == N)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
signed main(){
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))puts("A");
	else puts("B");
}

Measured memory_bytes: 256
def check(learn_total):
    for i in range(m):
        if learn_total[i] < x:
            return False
    return True


def calc_price(bit):
    price_total = 0  # 値段の合計
    learn_total = [0] * m  # 理解度

    for i in range(n):
        if (bit >> i) & 1:  # i桁目が0か1か見て、i番目を買うか買わないか判定します
            price_total += c[i]  # 買うので、i番目の値段を加算します
            learn = a[i]  # 「i番目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
            for j, le in enumerate(learn):  # 理解度を足します。 enumerateを使うと、range(n)よりスマートです
                learn_total[j] += le

    # 条件を満たすか、check関数で確認します
    if check(learn_total):
        return price_total
    else:
        return INF


if __name__ == '__main__':
    INF = float("inf")

    n, m, x = list(map(int, input().split()))

    # 空のリストを作って、appendで追加していきます
    c = []  # 参考書の値段です
    a = []  # 各参考書に入る理解度です

    for i in range(n):
        c_temp, *a_temp = list(map(int, input().split()))  # こうすると、2つ目以降をリストで受け取れます
        c.append(c_temp)
        a.append(a_temp)

    ans = INF

    for bit in range(1 << n):
        price = calc_price(bit)  # 条件を満たすなら価格、満たさないならINFが返ってきます
        ans = min(ans, price)  # 答えを更新します

    if ans == INF:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 68708
l = [int(i) for i in input().split()]
num = [1,0,-1]
c = 0
s = 0
k = l[-1]
for i in range(3):
    
    if c + l[i] > k:
        s += num[i] *(k-c)
        break
    else:
        s += l[i] * num[i]
        c+=l[i]
   
print(s)
        


Measured memory_bytes: 9192
from sys import exit
S = input()
N = len(S)
back_S = S[::-1]
if S != back_S:
    print("No")
    exit(0)

slice1_S = S[0:int((N-1)/2)]
back_s1S = slice1_S[::-1]
if slice1_S != back_s1S:
    print("No")
    exit(0)

slice2_S = S[int((N+3)/2)-1:N]
back_s2S = slice2_S[::-1]
if slice2_S != back_s2S:
    print("No")
    exit(0)

print("Yes")

Measured memory_bytes: 9092
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<int> b(m);
    for (int i = 0; i < n; i++) {
        int k;
        std::cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            std::cin >> a;
            b[a - 1]++;
        }
    }
    std::cout << std::count(b.begin(), b.end(), n);
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n,k,ans=1;
  std::cin >> n >>k;
  for(int i=1; i<=n; i++){
    if(ans*2>ans+k) ans=ans+k;
    else ans=ans*2;
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void setIO(string name = "a") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(), "r", stdin);
    freopen((name+".out").c_str(), "w", stdout);
}

int main() {
    //setIO();
    int n; cin >> n;
    vi v (2 * n);
    for (int i = 0; i < 2 * n; i++) {
        cin >> v[i];
    }
    sort(all(v));
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += v[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3600
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=pow(10,18);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const ll dx[4]={0,0,1,-1};
const ll dy[4]={-1,1,0,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n;cin>>n;
  vector<ll>A(3*n);
  rep(i,3*n)cin>>A[i];
  sort(all(A));
  ll ans=0;
  for(int i=n;i<3*n;i+=2){
    ans+=A[i];
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed;
  return solve();
}


Measured memory_bytes: 2560
import sys
input = sys.stdin.readline
R, C, ite = map(int, input().split())
items = [[0 for _ in range(C)] for _ in range(R)]
for _ in range(ite):
    r, c, v = map(int, input().split())
    items[r-1][c-1] = v

dp = [[0] * 4 for _ in range(C)]
dp[0][1] = items[0][0]
for i in range(R):
    for j in range(C):
        for k in range(4):
            if j == 0:
                continue
            
            if k == 0:
                dp[j][0] = max(
                    dp[j-1][0],
                    dp[j][0]
                )
            else:
                dp[j][k] = max(
                    dp[j][k],
                    dp[j-1][k],
                    dp[j-1][k-1] + items[i][j]
                )
    
    if i == R - 1:
        break

    new_dp = [[0] * 4 for _ in range(C)]
    for j in range(C):
        new_dp[j][0] = max(dp[j])
        if items[i+1][j] > 0:
            new_dp[j][1] = max(dp[j]) + items[i+1][j]

        dp[j] = new_dp[j].copy()

        
print(max(dp[-1]))


Measured memory_bytes: 230484
#include<bits/stdc++.h>
typedef long long int lli;

using namespace std;

int main(void){
    lli N, K;
    vector<lli> tree, sub;

    cin>>N>>K;
    tree.resize(N);
    lli ans = 10000000000;

    for(lli i=0; i<N; i++) cin>>tree[i];

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

    for(lli i=0; i<N-K+1; i++){
        ans = min({tree[i+K-1] - tree[i], ans});
    }

    cout<<ans<<endl;
}

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)

int main(){
    int n,x,y,cnt=0;
    sc1(n);
    vector <int> d(n);
    vector <int> p(n);
    vector <int> q(n);
    rep(i,n) d[i]=i+1;
    rep(i,n) sc1(p[i]);
    rep(i,n) sc1(q[i]);
    do {
        int w[2]={1,1};
        rep(i,n){
            if (p[i]!=d[i]) w[0]=0;
            if (q[i]!=d[i]) w[1]=0;
        }
        if (w[0]) x=cnt;
        if (w[1]) y=cnt;
        cnt++;

    } while(next_permutation(d.begin(),d.end()));
    printf("%d\n",abs(x-y));
    return 0;
}

Measured memory_bytes: 3708
import numpy as np

S = input()
N = int(S)
K = int(input())

keta = len(S)

ans = 0
if keta < K:
    print(ans)
    exit()

dp = np.zeros((keta+2,4,2), dtype = int)
dp[0][0][0] = 1
for i in range(keta):
    for j in range(4):
        for k in range(2):
            nd = int(S[i])
            for d in range(10):
                ni = i+1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k==0:
                    if d > nd: continue
                    if d < nd: nk=1
                dp[ni][nj][nk] += dp[i][j][k]

ans = dp[keta][K][0] + dp[keta][K][1]
print(ans)

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(int n){
    cout << "Yes" << endl;
}

void no (int n){
    cout << "No" << endl;
}

int ggcd(int a, int b){
    int c = a % b;
    while (c > 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n, m; cin >> n >> m;
    if (abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1LL;
    if (n == m) ans = 2LL;
    rep(i,n){
        ans *= i+1;
        ans %= mod;
    }
    rep(i,m){
        ans *= i+1;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

class UnionFind{
    private:
        int n;
        vector<int> uni;
    public:
        UnionFind(int _n){
            n = _n;
            uni.clear();
            uni.resize(n,-1);	// 値が負であれば根であり、かつ-1*値は頂点の数。値が正であればそれが親を表す。
        }
        int root(int x){
            if(uni[x]<0) return x;
            return uni[x] = root(uni[x]);
        }
        bool same(int x, int y){
            return root(x)==root(y);
        }
        void unite(int x, int y){
            x = root(x);
            y = root(y);
            if(x==y) return;
            if(uni[x]>uni[y]) swap(x,y);
            uni[x] += uni[y];
            uni[y] = x;
        }
        int getSize(int x){
            return -uni[root(x)];
        }
        void print(){
            for(auto x:uni) cout<<x<<" ";
            cout<<endl;
        }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;
    cin>>N>>M;
    if(M==N-1){
        cout1(0);
        return 0;
    }
    V A(N);
    rep(i,N) cin>>A[i];
    
    UnionFind uf(N+9);
    rep(i,M){
        int x,y; cin>>x>>y;
        uf.unite(x,y);
    }
    
    map<int,vector<int>> dic;
    rep(i,N){
        int r=uf.root(i);
        dic[r].push_back(A[i]);
    }
    
    ll sum=0;
    int cnt=0;
    vector<int> nums;
    for(auto d:dic){
        vector<int> v=d.second;
        sort(all(v)); cnt++;
        sum+=v[0]; v.erase(v.begin());
        nums.insert(nums.end(),v.begin(),v.end());
    }
    
    if(nums.size()+cnt<2*(N-M-1)){
        cout1("Impossible");
        return 0;
    }
    sort(all(nums));
    for(int i=0;cnt<2*(N-M-1);i++){
        sum+=nums[i]; cnt++;
    }
    cout1(sum);
}

Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {

	public static long MOD = 998244353;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		long[] comb =  new long[n+1];
		comb[0]=1;

		for (int i=1;i<=n;i++) {
			comb[i]=div(((comb[i-1]*(n-i+1))%MOD),i,MOD);
		}

		long ans = 0;

		for (int i=0;i<=n;i++) {
			if ((k-a*i)%b==0 && 0<=(k-a*i)/b && (k-a*i)/b <= n) {
				ans += comb[i]*comb[(int) ((k-a*i)/b)];
				ans %= MOD;
			}
		}
		System.out.println(ans);
	}

	public static long pow(long a, long b, long mod) {
		if(b==0) {
			return 1;
		} else {
			long c = pow(a,b/2,mod);
			return ((c*c%mod)*(b%2==1?a:1))%mod;
		}
	}

	public static long div(long a, long b, long mod) {
		return (a*pow(b,mod-2,mod)%mod);
	}


}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  string s;
  cin >> s;
 
  //              is lower
  int cnt = 1;
  vector<pair<long long, bool> > clumps;
  for (int i=1; i<s.size(); i++){
      if (s[i] != s[i-1]){
          clumps.emplace_back(cnt, (s[i-1] == '<'));
          cnt = 1;
      }else{
          cnt++;
      }
  }
  clumps.emplace_back(cnt, (s[s.size()-1] == '<'));
  
  if (clumps.size() == 1){
      cout << clumps[0].first*(clumps[0].first+1)/2;
      return 0;
  }
  long long sum = 0;
  for (int i=0; i<clumps.size()-1; i++){
      if (clumps[i].second && !clumps[i+1].second){
         if (clumps[i].first > clumps[i+1].first){
             sum += clumps[i].first;
         }else{
             sum += clumps[i+1].first;
         }
         sum += clumps[i].first*(clumps[i].first-1)/2;
         sum += clumps[i+1].first*(clumps[i+1].first-1)/2;
      }else{
          if (i == 0){
              sum += clumps[i].first*(clumps[i].first+1)/2;
          }
          if (i == clumps.size()-2){
              sum += clumps[i+1].first*(clumps[i+1].first+1)/2;
          }
      }
  }
  cout << sum;
  return 0; 
}


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

int main(){
    char x,y;
    cin >> x >> y;
    if(x<y) cout << "<" << endl;
    else if(x == y) cout << "=" << endl;
    else cout << ">" << endl;
    
    return 0;
}


Measured memory_bytes: 256
# cook your dish here
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[n-1])

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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		int[] cnt = new int[26];
		Arrays.fill(cnt, 0);
		while(sc.hasNext()){
			String s = sc.nextLine();
			s=s.toLowerCase();
			for(int i = 0; i < s.length(); ++i){
				char c = s.charAt(i);
				if('a' <= c && c <= 'z')
					++cnt[c - 'a'];
			}
		}
		for(int i = 0; i < 26; i++){
			System.out.print((char)(i + 'a'));
			System.out.printf(" : %d\n", cnt[i]);
		}
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 26284
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int N; cin >> N;
    map<int, int> M;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        M[a]++;
    }
 
    int ans = 0;
    for(auto m:M) if(m.second%2) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4864
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, A, B, C = map(int, input().split())
    L = []
    for _ in range(N):
        L.append(int(input()))

    ans = 10**9
    for i in range(4 ** N):
        AA = []
        BB = []
        CC = []
        ii = i
        for j in range(N):
            k = ii % 4
            if k == 0:
                AA.append(L[j])
            elif k == 1:
                BB.append(L[j])
            elif k == 2:
                CC.append(L[j])
            ii >>= 2
        if len(AA) * len(BB) * len(CC) == 0:
            continue
        ans_new = abs(sum(AA) - A) + 10*(len(AA)-1) + abs(sum(BB) - B) + 10*(len(BB)-1) + abs(sum(CC) - C) + 10*(len(CC)-1)
        ans = min(ans, ans_new)
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    ll h, k;
    cin>>h>>k;
    vector<ll>v;
    for(ll i=0; i<h; i++)
    {
        ll tmp;
        cin>>tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    ll  ans=0;
    for(ll i=0;i<h-k;i++){
        ans+=v[i];
    }
    cout<<ans<<endl;
    return 0;
}




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

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

  int sum=0;
  int X=N;
  while (X>0){
    sum+=X%10;
    X/=10;
  }

  if (N%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a[32]={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};
  int k;
  scanf("%d",&k);
  k=k-1;
  printf("%d",a[k]);
  return 0;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

char memo[1<<20];
int n;

int main(){
  {
    queue<int> q;
    int cost = 0;
    q.push(-1);
    q.push(0);
    memo[0] = 1;

    while(q.size() != 1){
      int state = q.front();
      q.pop();

      if(state == -1){
        cost++;
        q.push(-1);
        //printf("cost = %d, size = %d\n",cost,q.size());
        continue;
      }

      //printf("state: %x\n",state);

      for(int xs = 0; xs < 5; xs++){
        for(int xe = xs+1; xe <= 5; xe++){
          int mask = ((1<<xe) - 1) ^ ((1<<xs) - 1);
          for(int ys =  0; ys < 4; ys++){
            int next = state;
            for(int ye = ys; ye < 4; ye++){
              next ^= mask << (ye * 5);
              if(!memo[next]){
                q.push(next);
                memo[next] = cost+1;
              }
            }
          }
        }
      }
    }
  }

  while(n = getInt()){
    int ss = 0;
    REP(i,n) REP(j,n){
      int t = getInt();
      ss |= (t << (j + i*5));
    }

    queue<int> q;
    int cost = 0;
    const int mm = ((1<<25)-1) ^ ((1<<20)-1);
    set<int> f;
    q.push(ss);
    f.insert(ss);
    q.push(-1);

    int ans = INT_MAX;
    while(q.size() != 1){
      int state = q.front();
      q.pop();

      if(state == -1){
        cost++;
        q.push(-1);
        //printf("cost = %d, size = %d\n",cost,q.size());
        if(cost >= ans - 1) break;
        continue;
      }

      if((state & mm) == 0){
        ans = min(ans, cost + memo[state] - 1);
      }

      for(int xs = 0; xs < 5; xs++){
        for(int xe = xs+1; xe <= 5; xe++){
          int mask = ((1<<xe) - 1) ^ ((1<<xs) - 1);
          for(int ys =  0; ys < 5; ys++){
            int next = state;
            for(int ye = ys; ye < 5; ye++){
              next ^= mask << (ye * 5);
              if(ye == 4 && !f.count(next)){
                if(cost + 1 + memo[next & ((1<<20) - 1)] < ans){
                  f.insert(next);
                  q.push(next);
                }
              }
            }
          }
        }
      }
    }
    while(ans --> 0) printf("myon");
    puts("");
  }

  return 0;
}

Measured memory_bytes: 4460
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	ull res = 0;
	int n = s.length() - 1;
	for (int i = 0; i < (1 << n); i++)
	{
		int l = 0;
		for (int j = 0; j < n; j++)
		{
			if (i & 1 << j)
			{
				res += stoll(s.substr(l, j + 1 - l));
				l = j + 1;
			}
		}
		res += stoll(s.substr(l));

	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
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() {
  string s, t, u;
  cin >> s >> t >> u;
  string ans = "";
  ans += s[0] - 32;
  ans += t[0] - 32;
  ans += u[0] - 32;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,m,bit[15],tmp[15],i,j,k,tgt[15],tgb[15],sw,bitsum=0,tgsum=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&bit[i]);
		tmp[i]=bit[i];
		bitsum+=bit[i];
	}
	for(i=0;i<m;i++){
		scanf("%d",&tgt[i]);
	}
	i=j=k=0;
	sw=0;
	while(1){
		if(sw%2==0){
			tgb[k]=0;
		}
		else{
			tgb[k]=1;
			tgsum++;
		}
		k++;
		i++;
		if(i==tgt[j]){
			j++;
			sw++;
			i=0;
		}
		if(j==m){
			break;
		}
	}
	//0start
	int zero=0;
	if(bitsum==tgsum){
		while(1){
			sw=0;
			for(i=0;i<n;i++){
				if(tgb[i]!=tmp[i]){
					sw++;
					break;
				}
			}
			if(sw==0){
				break;
			}
			for(i=0;i<n;i++){
				if(tgb[i]!=tmp[i]){
					k=i;
					break;
				}
			}
			for(i=k+1;i<n;i++){
				if(tmp[k]!=tmp[i]){
					zero+=i-k;
					j=tmp[k];
					tmp[k]=tmp[i];
					tmp[i]=j;
					break;
				}
			}
		}
	}
	else{
		zero=1000000;
	}
	for(i=0;i<n;i++){
		if(tgb[i]==1){
			tgb[i]=0;
		}
		else{
			tgb[i]=1;
		}
	}
	for(i=0;i<n;i++){
		tmp[i]=bit[i];
	}
	//1start
	int one=0;
	tgsum=n-tgsum;
	if(bitsum==tgsum){
		while(1){
			sw=0;
			for(i=0;i<n;i++){
				if(tgb[i]!=tmp[i]){
					sw++;
					break;
				}
			}
			if(sw==0){
				break;
			}
			for(i=0;i<n;i++){
				if(tgb[i]!=tmp[i]){
					k=i;
					break;
				}
			}
			for(i=k+1;i<n;i++){
				if(tmp[k]!=tmp[i]){
					one+=i-k;
					j=tmp[k];
					tmp[k]=tmp[i];
					tmp[i]=j;
					break;
				}
			}
		}
	}
	else{
		one=1000000;
	}
	if(one>zero){
		printf("%d\n",zero);
	}
	else{
		printf("%d\n",one);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}
template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
void solve(){
    int n;
    read(n);
    vl A(n+1);
    vl B(n);
    REP(i,n+1) cin >> A[i];
    REP(i,n) cin >> B[i];
    ll monster_count = 0;
    for(int i = 0 ; i < n ; i++){
        if( B[i] > A[i]){
            monster_count += A[i];
        }else{
            monster_count += B[i];
            continue;
        }
        B[i] -= A[i];
        if(B[i] > A[i+1]){
            monster_count += A[i+1];
            A[i+1] = 0;
        }else{
            monster_count += B[i];
            A[i+1] -= B[i];
        }
    }
    cout << monster_count << "\n";
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 4716
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A, B = LS()
    ans = ''
    for i in range(N):
        ans += A[i]
        ans += B[i]
    print(ans)


main()



Measured memory_bytes: 5936
n = int(input())

nums = []
for i in range(9):
    if i == 0:
        nums_tmp = ['7', '5', '3']
    else:
        nums_tmp_tmp = []
        for num in nums_tmp:
            nums_tmp_tmp.extend([num + d for d in ('7', '5', '3')])
        nums_tmp = nums_tmp_tmp
    nums.extend(nums_tmp)

ans = 0
for num in nums:
    if ('7' in num) and ('5' in num) and ('3' in num) and (int(num) <= n):
        ans += 1
print(ans)


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

    return divisors

n = int(input())
l1 = make_divisors(n)
l2 = make_divisors(n-1)
l1_l2_sym_diff = list((set(l1) ^ set(l2)) & set(l2))
ans = len(l1_l2_sym_diff)
for i in range(1, len(l1)):
    n1 = n 
    while n1 % l1[i] == 0:
        n1 = n1//l1[i]
    if (n1-1) % l1[i] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 4680
n, q = gets.chomp.split.map(&:to_i)
A = []
n.times{ 
    A.push([])
}

q.times{
    choice, t, x = gets.chomp.split(" ").map(&:to_i)
    case choice
    when 0
        A[t].push(x)
    when 1
        puts A[t][0] unless A[t][0].nil?
    when 2
        A[t].shift
    end
    }


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

int main()
{
    int N, T;
    int c, t;
    int result = 1001;
    int i;

    cin >> N >> T;

    for(i = 0; i < N; ++i) {
        cin >> c >> t;
        if(t <= T) result = min(result, c);
    }

    if(result == 1001) {
        cout << "TLE";
    } else {
        cout << result;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n, flag = 0;
  long long arr[100000];
  long long temp = 1;
  scanf("%d",&n);
  for(int i = 0; i < n ; i++)
  {
     scanf("%lld", &arr[i]);
  }
  
  for(int i = 0; i < n; i++)
  {
     if(arr[i] == 0)
     {
     	flag = 1;
	 }
	 if(flag == 1)
	 {
	 	printf("0\n");
	 	return 0;
	 }
  }
  
  for(int i = 0; i < n;i++)
  {
    if(arr[i]<=1000000000000000000/temp)
	{
      temp = temp * arr[i];
    }
    else
	{
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld", temp);
  return 0;
}

Measured memory_bytes: 2488
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    ll ans=1;
    for(ll i=2;i<=n;i++){
        ans*=i;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#pragma region Header
#define _CRT_SECURE_NO_WARNINGS
#define FOR(i,s, e) for(int i = s; i<e; ++i)
#define rFOR(i,s, e) for(int i=s-1; i>=e; --i)
#define loop(len) for(int i=0; i<len; ++i)
#define rloop(len) for(int i=len-1; i>=0; --i)
#define iPair pair<int,int>
#define LPair pair<ll,ll>
#define vecP(t,t2) vector<pair<t,t2>>
#define uoMP(t, t2) unordered_map<t, t2>
#define pb push_back
#define pp pop_back
#define beg_end(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define MrN ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long  ll;
typedef long double  ld;
#include<bits/stdc++.h>
using namespace std;
#pragma endregion

ll a;
int main() {
	MrN;
	// freopen("input.txt", "r", stdin);
	cin >> a;
	cout << a + a*a + a*a*a << '\n';
	return 0;
}

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

 
int main() {
  int n;
  scanf("%d", &n);
  int64_t b, c, d;
  if(n==0) b = 2LL;
  else if(n==1) b = 1LL;
  else{
    c = 2LL;
    b = 1LL;
    for(int i=0; i<n-1; i++){
      d = b;
      b = c+b;
      c=d;
  }
  }
  printf("%lld\n", b);
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int d, n; cin >> d >> n;
    if(d == 0) {
        if(n == 100) cout << 101 << endl;
        else cout << n << endl;
    }
    else if(d == 1) {
        if(n == 100) cout << 101 * 100 << endl;
        else cout << 100 * n << endl;
    }
    else if(d == 2) {
        if(n == 100) cout << 10000 * 101 << endl;
        else cout << 10000 * n << endl;
    }
}

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

int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0;i < N;i++) {
		cin >> H.at(i);
	}

	int count=0, max=0;
	for (int i = 0; i < N;i++) {
		if (H.at(i) >= max) {
			count++;
			max = H.at(i);
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, K = ni()
    val D = na(K)
    var ans = N

    def ok(n: Int) = {
      n.toString map (_ - '0') forall (!D.contains(_))
    }

    while(!ok(ans)) {
      ans += 1
    }
    out.println(ans)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    rep(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    int x, y, s;

    for (;;) {
        cin >> x >> y >> s;
        if (!x && !y && !s)
            break;

        int ans = 0;
        for (int i = 1; i <= s - 1; i++)
            for (int j = 1; j <= s - 1; j++)
                if (i * (100 + x) / 100 + j * (100 + x) / 100 == s)
                    ans = max(ans, i * (100 + y) / 100 + j * (100 + y) / 100);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <set>
using namespace std;

int main() {
	int n;
	string s;
	cin>>n;
	cin>>s;
	size_t ans=0;
	for (int i=1; i<s.length(); ++i) {
		string l=s.substr(0, i);
		string r=s.substr(i);
		sort(l.begin(), l.end());
		sort(r.begin(), r.end());
		vector<char> v(l.length()+r.length());
		vector<char>::iterator it;
		it=set_intersection(l.begin(), l.end(), r.begin(), r.end(), v.begin());
		v.resize(it-v.begin());
		set<char> ss;
		for (auto e : v) ss.insert(e);
		ans=max(ans, ss.size());
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A = A
f = 0
ans = 1
for k in range(N-1):
    if f == 0:
        if A[k] > A[k+1]:
            f = -1
        elif A[k] < A[k+1]:
            f = 1
    elif f == 1:
        if A[k] > A[k+1]:
            ans += 1
            f = 0
    else:
        if A[k] < A[k+1]:
            ans += 1
            f = 0
print(ans)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
vector <int> a1[100010],a2[100010];
int n,m,f[100010],ind[100010],cnt,topo[100010],ans;
void toposort()
{
	queue <int> q;
	for(int i=1;i<=n;i++)
		if(!ind[i])
			q.push(i);
	while(!q.empty())
	{
		int p=q.front();
		q.pop();
		for(int i=0;i<a2[p].size();i++)
		{
			ind[a2[p][i]]--;
			if(!ind[a2[p][i]])
				q.push(a2[p][i]);
		}
		topo[cnt++]=p;
	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		ind[v]++;
		a1[v].push_back(u);
		a2[u].push_back(v);
	}
	toposort();
	for(int i=0;i<cnt;i++)
	{
		for(int j=0;j<a1[topo[i]].size();j++)
			f[topo[i]]=max(f[topo[i]],f[a1[topo[i]][j]]+1);
		ans=max(ans,f[topo[i]]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12416
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[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||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  LL i,N,ans=0;
  cin>>N;
  LL H[N];
  rep(i,N)cin>>H[i];
  rep(i,N-1){
    if(H[i+1]>H[i])H[i+1]--;
    if(H[i]>H[i+1])ans=1;
  }
  Yn(!ans);
}


Measured memory_bytes: 1024
#include <stdio.h>

int main (){
	int n;
	scanf ("%d", &n);
	
	int num1 = n / 100;
	int num2 = (n / 10) % 10;
	int num3 = n % 10;
	
	while (n > 0){
		if (num1 == 7) {
			printf ("Yes");
			break;
		}
		else if (num2 == 7){
			printf ("Yes");
			break;
		}
		else if (num3 == 7){
			printf ("Yes");
			break;
		}
		else{
			printf ("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1684
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        System.out.println(Integer.max(0, d[n / 2] - d[n / 2 - 1]));
    }
}


Measured memory_bytes: 51044
n = int(input())
a = [int(_) for _ in input().split()]
div4 = 0
div2 = 0
for i in a:
    if i % 4 == 0:
        div4 += 1
    elif i % 2 == 0:
        div2 += 1
odd = n - div4 - div2

if div2 % 2 == 0:
    if odd-1 <= div4:
        print('Yes')
    else:
        print('No')
else:
    if odd <= div4:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 25;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int n, a[N];
int f(int l, int r, int x, int y) {
	int res = 1e18;
	if(l + 1 == r) return 0;
	for(int i = l + 1; i < r; ++ i) res = min(res, f(l, i, x, x + y) + f(i, r, x + y, y) + a[i] * (x + y));
	return res;
}
signed main() {
	n = read();
	for(int i = 1; i <= n; ++ i) a[i] = read();
	printf("%lld\n", f(1, n, 1, 1) + a[1] + a[n]);
	return 0;
}

Measured memory_bytes: 256