akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

pair<ll,ll> fnfi(ll N){
    pair<ll,ll> target;
    ll keta = log10(N);
    target.first = N % 10;
    rep(i,keta){
        N /= 10;
    }
    target.second = N;
    return target;
}

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

    ll N;
    cin >> N;

    vector<vector<ll>> Cij(10,vector<ll>(10,0));

    // cout << "kokoka?" << "\n";
    rep(i,N){
        ll target = i + 1;
        pair<ll,ll> ff = fnfi(target);
        // cout << "target:" << target << "\n";
        // cout << ff.first << "," << ff.second << "\n";
        Cij[ff.first][ff.second]++;
    }

    ll total = 0;
    rep(i,10)rep(j,10){
        // cout << i << "," << j << ":" << Cij[i][j] * Cij[j][i] << "\n";
        total += Cij[i][j] * Cij[j][i];
    }

    cout << total;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

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

Measured memory_bytes: 1164
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int H, W; cin >> H >> W;
  vector<vector<char>> C(H, vector<char>(W));
  vector<vector<int>> dist(H, vector<int>(W, INT_MAX));
  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      cin >> C[y][x];
    }
  }

  deque<pair<int, int>> que;
  que.push_back({0, 0});

  if (C[0][0] == '#') dist[0][0] = 1;
  else                dist[0][0] = 0;

  vector<pair<int, int>> ds = {{1, 0}, {0, 1}};
  while (!que.empty()) {
    auto p = que.front(); que.pop_front();
    int x = p.first;
    int y = p.second;

    for (auto dxy : ds) {
      int nx = x + dxy.first;
      int ny = y + dxy.second;
      if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;

      if (C[ny][nx] == '.' || C[ny][nx] == C[y][x]) {
        if (dist[ny][nx] > dist[y][x]) {
          dist[ny][nx] = dist[y][x];
          que.push_back({nx, ny});
        }
      } else {
        if (dist[ny][nx] > dist[y][x] + 1) {
          dist[ny][nx] = dist[y][x] + 1;
          que.push_back({nx, ny});
        }
      }
    }
  }

#if 0
  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      cout << dist[y][x] << " ";
    }
    cout << endl;
  }
#endif

  cout << dist[H-1][W-1] << endl;
}


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

typedef long long LL;

LL t,n,m,ans;
LL f[11];

int main()
{
	LL u,v,p;
	cin>>f[0]>>f[1]>>f[2];
	sort(f,f+3);
	ans+=(f[2]-f[0])/2;
	f[0]+=(f[2]-f[0])/2*2;
	ans+=(f[2]-f[1])/2;
	f[1]+=(f[2]-f[1])/2*2;
	sort(f,f+3);
//	cout<<f[0]<<" "<<f[1]<<" "<<f[2]<<endl;
	if(f[1]==f[2]&&f[1]!=f[0])ans+=2;
	if(f[1]==f[0]&&f[1]!=f[2])ans+=1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
list = list(map(int, input().split()))
co = 0
for i in range(n):
	k = list[i]
	if k%2==0:
		if k%3!=0 and k%5!=0:
			co=1
if co==0:
	print("APPROVED")
else:
	print("DENIED")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int sw;
		int N;
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();

		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		sw = selectionSort(A, N);

		System.out.print(A[0]);
		for (int i = 1; i < N; i++) {
			System.out.print(" " + A[i]);
		}
		System.out.println("\n" + sw);
	}

	private static int selectionSort(int[] A, int N) {
		int sw = 0;
		int minj = 0;
		for (int i = 0; i < N - 1; i++) {
			minj = i;
			for (int j = i + 1; j < N; j++) {
				if (A[j] < A[minj])
					minj = j;
			}
			int temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;

			if (i != minj) {
				sw++;
			}
		}
		return sw;
	}

}



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

int main(){
    int H, W;
    while(1) {
        cin >> H >> W;
        
        if ( H == 0 && W == 0) break;
        
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ( (i + j) % 2 == 0) {
                    cout << "#";
                    
                }
                else {
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        a: u64,
        b: String,
    }

    let v: Vec<_> = b.split('.').collect();
    let b_int: u64 = v[0].parse().unwrap();
    let b_dec: u64 = v[1].parse().unwrap();

    let mut ans = a * b_int + (a * b_dec) / 100;
    println!("{}", ans);
}


Measured memory_bytes: 2168
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

# 逆元の前計算
factorial = [1, 1]
inverse = [1, 1]
invere_base = [0, 1]
for i in range(2, K + 1):
    factorial.append((factorial[-1] * i) % MOD)
    invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)
    inverse.append((inverse[-1] * invere_base[-1]) % MOD)


# フェルマーの小定理を用いたMOD上Combination
def nCr(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


# 包除原理
ans = pow(K, N, MOD)
for r in range(1, K + 1):
    ans -= ((-1) ** ((r % 2) ^ 1)) * nCr(K, r) * pow(K - r, N, MOD) % MOD

print(ans % MOD)



Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a,ll b)
{
    return (a>b?a:b);
}
int main()
{
    ll N,M;
    cin>>N>>M;
    ll gcd=1,i;
    for(i=1;i*i<=M;i++)
    {
        if(M%i==0)
        {
            ll factor_1=i,factor_2=M/i;
            if(factor_1*N<=M) gcd=max(gcd,factor_1);
            if(factor_2*N<=M) gcd=max(gcd,factor_2);
        }
    }
    cout<<gcd<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int A, B; cin >> A >> B;
  int ans = 0;
  if(A < B) swap(A, B);
  ans += A, A--;
  if(A < B) swap(A, B);
  ans += A;
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define MAX 8
#define square(n) (n)*(n)

int main(void)
{
  int N;
  int xy[MAX][2];
  int i,j;
  double sum_each_len=0;
  double ave_len=0;

  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d %d",&xy[i][0],&xy[i][1]);

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      sum_each_len += sqrt(square(xy[i][0]-xy[j][0])+square(xy[i][1]-xy[j][1]));
    }
  }

  ave_len = sum_each_len * 2 / N;
  printf("%lf\n",ave_len);

  return 0;
}








Measured memory_bytes: 128
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7,V=4000001;

bitset<V> a;
int n,cnt,b[V],sum;

int main(){
	a.set(0);
	scanf("%d",&n);
	rep(i,1,n){
		int x;
		scanf("%d",&x);
		a|=(a<<x);
		sum+=x;
	}
	rep(i,0,sum){
		if(a.test(i)) b[++cnt]=i;
	}
	printf("%d\n",b[(cnt>>1)+1]);
	return 0;
} 

Measured memory_bytes: 9856
n, k = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])

ab = sorted(ab)

count = 0

for a, b in ab:
    count += b
    if k <= count:
        print(a)
        exit()

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

int main() {
  int r, g, b;
  string op;
  cin >> r >> g >> b;

  if ((100*r+10*g+b)%4 == 0) {
    cout << "YES" << endl;
  }
 
  else{
    cout << "NO" << endl;
  }
}

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

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string>s(H);
	rep(i, H)cin >> s[i];
	vector<vector<int>>ans(H, vector<int>(W, 0));
	int id = 1;
	rep(i, H)rep(j, W) {
		if (s[i][j] == '#') {
			ans[i][j] = id;
			id++;
		}
	}
	rep(i, H)for(int j = 1; j < W; j++) {
		if (ans[i][j] == 0)ans[i][j] = ans[i][j - 1];
	}
	rep(i, H)for (int j = W - 2; j >= 0; j--) {
		if (ans[i][j] == 0)ans[i][j] = ans[i][j + 1];
	}
	rep(i, W)for (int j = 1; j < H; j++) {
		if (ans[j][i] == 0)ans[j][i] = ans[j - 1][i];
	}
	rep(i, W)for (int j = H - 2; j >= 0;  j--) {
		if (ans[j][i] == 0)ans[j][i] = ans[j + 1][i];
	}
	rep(i, H) {
		rep(j, W) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1664
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{

	ll n;
	cin >> n;
	vll arr(n);
	for (ll i = 0; i < n; i++)
		cin >> arr[i];
	ll count = 0;
	for (ll i = 0; i < n; i++)
	{
		for (ll j = i + 1; j < n; j++)
		{
			for (ll k =  j + 1; k < n; k++)
			{
				set<ll> st;
				st.insert(arr[i]);
				st.insert(arr[j]);
				st.insert(arr[k]);
				if (st.size() == 3)
				{
					auto a = st.begin();
					ll one = *a;
					a++;
					ll two = *a;
					a++;
					ll three = *a;
					if (one + two > three)
						count++;

				}
			}
		}
	}
	cout << count << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <math.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k ;
  int i, ans;
  ans = 1 ;
  if (n == 1) {
  cout << k << endl;
  } else{
  ans = ans * k;
  for (int i =1; i < n; i++){
  ans = ans * (k-1);
  }
  cout << ans << endl;
  }
  return 0;
 
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
dis = []
count = 0
for i,j in zip(a,b):
    if j > i:
        ans += 1
        count += j-i
    else:
        dis.append(i-j)
dis.sort(reverse=True)
if count > 0 and dis == []:
    print(-1)
else:
    now = 0
    while now < len(dis) and count > 0:
        ans += 1
        count -= dis[now]
        now += 1
    if count > 0:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 24228
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> m(h);
    vector<vector<int>> c(h, vector<int>(w, -1));
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    for (int i = 0; i < h; i++) {
        cin >> m[i];
    }
    // queue<pair<int, int>> q;
    stack<pair<int, int>> q2;
    stack<pair<int, int>> s;
    s.push(make_pair(ch, cw));
    c[ch][cw] = 0;
    auto check = [&](int i, int j) {
        if (i < 0 || j < 0 || i >=h || j >= w) {
            return false;
        }
        if (c[i][j] != -1 || m[i][j] != '.') {
            return false;
        }
        return true;
    };
    do {
        while (!s.empty()) {
            auto p = s.top();
            if (p.first == dh && p.second == dw) {
                cout << c[p.first][p.second] << endl;
                return 0;
            }
            q2.push(p);
            s.pop();
            // cout << "move ";
            auto move = [&](int i, int j) {
                    // cout << "move "<< i<<j<<endl;
                if (check(i, j)) {
                    s.push(make_pair(i, j));
                    c[i][j] = c[p.first][p.second];
                }
            };
            move(p.first + 1, p.second);
            move(p.first - 1, p.second);
            move(p.first, p.second + 1);
            move(p.first, p.second - 1);
        }
        while (!q2.empty()) {
            auto p = q2.top();
            q2.pop();
            // cout << "try wrap "<< p.first<<p.second<<endl;
            auto wrap = [&](int i, int j) {
                if (check(i, j)) {
                    // cout << "wrap "<< i<<j<<endl;
                    s.push(make_pair(i, j));
                    c[i][j] = c[p.first][p.second] + 1;
                }
            };
            wrap(p.first + 1, p.second + 1);
            wrap(p.first - 1, p.second + 1);
            wrap(p.first + 1, p.second - 1);
            wrap(p.first - 1, p.second - 1);
            for (int i = 0; i < 5; i++) {
                wrap(p.first - 2, p.second - 2 + i);
                wrap(p.first - 2 + i, p.second - 2);
                wrap(p.first + 2, p.second - 2 + i);
                wrap(p.first - 2 + i, p.second + 2);
            }
        }
    } while (!s.empty());
    cout << -1 << endl;
}


Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int ans = 1;
	for(int i = 1; i < N; i++) {
		if(S[i - 1] != S[i]) ans++;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 512
n=int(input())
m = int(pow(n,1/2)) + 1
k = 0
for i in range(n+1):
  if n < pow(i,2):
    break
  if k <= pow(i,2):
    k = pow(i,2)  
  for z in range(3,n):
    if n < pow(i,z):
      break
    elif k <= pow(i,z):
      k = pow(i,z)
 
print(k)

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

int n;

int main() {
  map<string, bool> d;
  string q, s;
  scanf("%d ", &n);
  for (int i=0; i<n; i++) {
    char qq[7], ss[13];
    scanf("%s%s ", qq, ss);
    q = qq; s = ss; 
//    cin >> q >> s;  //cin?????£???TLE
    if (q == "insert")
      d[s] = true;
    else if (q == "find") {
      puts((d.count(s)) ? "yes" : "no");
/*      if (d.count(s))
        printf("yes\n");
      else
        printf("no\n");
*/
    }
  }

  return 0;
}

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

int main() {
  string s; cin >> s;
  string out = "Yes";
  int ind = 0;
  if(s.size() % 2 == 1){
    cout << "No";
    return 0;
  }
  for(int i = 0; i < s.size(); i++){
    if(ind == 0){
      if(s.at(i) == 'h'){
        ind = 1;
        continue;
      }else{
        out = "No";
        break;
      }
    }else{
      if(s.at(i) == 'i'){
        ind = 0;
        continue;
      }else{
        out = "No";
        break;
      }
    }
  }
  cout << out;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;



























int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<P>> a(N + 1, vector<P> (0));
    for (long long i = 0; i < M; i++) {
        long long p, y;
        cin >> p >> y;
        a[p].push_back(P (y, i + 1));
    }

    for(int i = 1; i <= N; i++) {
        sort(a[i].begin(), a[i].end());
    }

    vector<long long> ans(M + 1);
    for(long long i = 1; i <= N; i++) {
        for(int j = 0; j < a[i].size(); j++) {
            P q = a[i][j];
            ans[q.second] = i * 1000000 + j + 1;
        }
    }


    for(int i = 1; i <= M; i++) {
        int keta = 0;
        long long b = ans[i] / 1000000;
        while (b) {
            keta++;
            b /= 10;
        }
        for (int j = 0; j < 6 - keta; j++) {
            cout << 0;
        }
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 9352
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> a(N);
  for (int i = 1; i <= N; ++i) {
    LL v; std::cin >> v;
    a[i-1] = v - i;
  }
  std::sort(a.begin(), a.end());
//  for (int v : a) std::cout << v << " ";
//  std::cout << std::endl;

  if (N%2 == 0) {  // even
    int mid1 = N/2 - 1;
    int mid2 = N/2;

    LL sum1 = 0, sum2 = 0;
    for (int i = 0; i < N; ++i) {
      sum1 += std::abs(a[i] - a[mid1]);
      sum2 += std::abs(a[i] - a[mid2]);
    }
//    std::cout << sum1 << " " << sum2 << std::endl;
    std::cout << std::max(sum1, sum2) << std::endl;
  } else {  // odd
    int mid = (N-1)/2;
    LL sum = 0;
    for (int i = 0; i < N; ++i) {
      sum += std::abs(a[i] - a[mid]);
    }
    std::cout << sum << std::endl;
  }
}


Measured memory_bytes: 1024
#include<stdio.h>

 long long int w[100000];
 long long int P,n,truck;

 long long int count(int P){
          long long int i,sum;
          i=0;
          for(long long int j=0;j<truck;j++){
                          sum=0;
                          while(sum+w[i]<=P){
                                   sum+=w[i];
                                   i++;
                                   if(i==n)return n;
                                   }
                          }
          return i;
          }
          

 long long int solve(){
          long long int mid,right,left,v;
          left=0;
          right=100000*10000;

          while(right-left>1){
                   mid=(left+right)/2;
                   v=count(mid);
                   if(v>=n)right=mid;
                   else left=mid;
                   }
         return right;
         }
                  


 int main(){
       int i,ans;
       scanf("%d%d",&n,&truck);
       for(i=0;i<n;i++){
                  scanf("%d",&w[i]);
                  }
       ans=solve();
       printf("%d\n",ans);
       return 0;
       }
       


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
//using System.Linq;
class Program
{
  //static List<string> list;
  //static List<int> primes = new List<int>{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,
  //                              59,61,67,71,73,79,83,89,97};
	static void Main(string[] args)
	{
		// 入力フェーズ
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);

        List<List<int> > birth = new List<List<int> >(); // 要素数Nのリストをつくる
        for(int i=0; i<N; i++)
        {
          List<int> list = new List<int>();
          birth.Add(list);
        }
        // 所属する県  生まれた年 の入力
        int[] year = new int[M];
        for(int i=0; i<M; i++)
        {
          string[] py = Console.ReadLine().Split(' ');
          int P = int.Parse(py[0]);
          int Y = int.Parse(py[1]);
          birth[P-1].Add(Y);
          year[i] = Y;
        }

        // [生まれたとし]をキーに、認識番号を生成する
        Dictionary<int, string> idList = new Dictionary<int, string>();
        for(int i=0; i<N; i++)
        {
          List<int> list = birth[i];
          list.Sort();
          for(int j=0; j<list.Count; j++)
          {
            // 県番号 i+1, 市の番号 j+1
            string id = String.Format("{0:000000}", i+1)
                            + String.Format("{0:000000}", j+1);
            idList[list[j]] = id;
          }
        }





    // 出力
        //Console.WriteLine(strct + 1);
        for(int i=0; i<M; i++)
        {
          string id = idList[year[i]];
          Console.WriteLine(id);
        }
    }
		class layer{ //自作クラス
			public long total {set; get;} // 全部の層数
			public long paty {set; get;}  // パティの数
      public long banz {set; get;}  // バンズの数
		}
}


Measured memory_bytes: 39336
n, m = map(int, input().split())
dp = [ [float("inf")]*(2**n) for _ in range(m) ]
dp[0][0] = 0
for i in range(1, m):
  a, b = map(int, input().split())
  k = set(map(int, input().split()))
  c = 0
  for l in k:
    c += 2**(l-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j&(~c)]+a, dp[i-1][j])

if dp[m-1][2**n-1] == float("inf"):
  print(-1)
else:
  print(dp[m-1][2**n-1])

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

class Main {
	public static final int M = 48828125;
	public static boolean[] H = new boolean[M];	
    public static void main( String[] args ) {
        try {
 	      	BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        	
        	int n = Integer.parseInt( kb.readLine( ) );
			String[] str = new String[3];
			for( int i=0; i<n; i++ ) {
				str = kb.readLine( ).split( " " );
				if( "insert".equals( str[0] ) ) {
					insert( str[1] );
				} else if( "find".equals( str[0] ) ) {
					if( find( str[1] ) ) {
						System.out.println( "yes" );
					} else {
						System.out.println( "no" );
					}
				}
			}
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
    
   public static int getChar( char ch )
   {
		if( ch == 'A') {
			return 1;
		} else if( ch == 'C') {
			return 2;
		} else if( ch == 'G') {
			return 3;
		} else if( ch == 'T') {
			return 4;
		}
		return 0;
	}
	public static int getKey( String str )
	{
		int i;
		int key = 0, base = 1;
		for ( i=0; i<str.length(); i++ ) {
			key += base*( getChar( str.charAt( i ) ) );
			base *= 5;
		}
		return key;
	}
	
	public static boolean find( String str )
	{
		if( true == H[ getKey( str ) ] ) {
			return true;
		} else {
			return false;
		}
	}
	
	public static void insert( String str )
	{
		H[ getKey( str ) ] = true;
		return;
	}	
}

Measured memory_bytes: 204456
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
vector<int>adj[100005];
set<int>st;
bool vis[100005];
void dfs(int node){
  if(vis[node])
    return;
  vis[node]=true;
  st.insert(node);
  for(auto to:adj[node])
  dfs(to);
}
vector<int>radj[100005];
int out[100005];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  int n,m,k;
  cin>>n>>m>>k;
  f(i,0,m){
    int u,v;
    cin>>u>>v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  f(i,0,k){
    int u,v;
    cin>>u>>v;
    radj[u].pb(v);
    radj[v].pb(u);
  }

  f(i,1,n+1){
    if(!vis[i]){
      st.clear();
      dfs(i);
      for(auto x:st){
        int ans = st.size()-1;
        for(auto y:adj[x])if(st.count(y))ans--;
        for(auto y:radj[x])if(st.count(y))ans--;
        out[x]=ans;
      }
    }
    cout<<out[i]<<' ';
  }


  return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main() {
  ll n, k;
  cin >> n >> k;
  vl a(n), b(n);
  rep (i, n) {
    cin >> a[i] >> b[i];
  }
  ll ans = 0;
  for (int c = 31; c >= 0; c--) {
    ll mask = 1LL << c;
    if ((k & mask) == 0) {
      continue;
    }
    ll temp = 0;
    rep (i, n) {
      bool flag = true;
      ll mask = 1LL << c;
      if ((a[i] & mask) != 0) {
        continue;
      }
      for (int j = c + 1; j <= 31; j++) {
        mask = 1LL << j;
        if ((k & mask) == 0 && (a[i] & mask) != 0) {
          flag = false;
          break;
        }
      }
      if (flag) {
        temp += b[i];
      }
    }
    ans = max(ans, temp);
  }
  ll temp = 0;
  rep (i, n) {
    if ((a[i] & k) == a[i]) {
      temp += b[i];
    }
  }
  chmax(ans, temp);
  cout << ans << endl;
}
  
  


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

int main(){
    int n;
    cin >> n;
    vector<int> num(n);
    for(int i = 0;i < n;i++){
        int a;cin >> a;
        a--;
        num[a] = i;
    }
    for(int i = 0;i < n;i++){
        cout << num[i] + 1 << " ";
    }
    //cin >> n;  
}

Measured memory_bytes: 1152
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[]$) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int ans=0;
        //辺iを切断(切断する辺をかえていく)
        for (int i = 0; i <m ; i++) {
            //UFを用意(初期化)
            UF.init();
            for (int j = 0; j <m ; j++) {
                //切断操作(i==jのときは追加しない)
                if(i!=j) {
                    //辺の追加(辺i以外)
                    UF.unite(a[j], b[j]);
                }
            }
            //グラフが非連結なら異なる根をもつ頂点の組が存在するので、それをさがす
            for(int j=2;j<=n;j++){
                if(!UF.same(1,j)){
                    ++ans;
                    //一つ見つけたら非連結とわかるのでLoopを抜ける
                    break;
                }
            }
        }
        out.println(ans);
    }
    static class UF{
        static int size=51;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
signed main(){
	scanf("%lld%lld",&l,&r);
	if (l==r){
		puts("1");
		return 0;
	}
	long long h=1;
	while (h*2<=(l^r))h*=2;
	l&=h+h-1;r&=h+h-1;
	long long p=1;
	while (p<=r-h)p*=2;
	printf("%lld\n",h-l+(p>l?h:h-l+p));
	return 0;
}

Measured memory_bytes: 256
# include<bits/stdc++.h>
using namespace std;
vector<int>dp(100000,-1);
vector<int> h;
int c(int i)
{
	if(dp[i]!=-1)
      return dp[i];
  	if(i==0) return 0;
  	if(i==1) return abs(h[1]-h[0]);
  	dp[i]=min(abs(h[i]-h[i-1])+c(i-1),abs(h[i]-h[i-2])+c(i-2));
  	return dp[i];
}

int main()
{
	int n,i,ans;
  	cin>>n;
  	h.resize(n);
  	for(i=0;i<n;i++)
      cin>>h[i];
  	ans=c(n-1);
  	cout<<ans;
return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
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;}
const int INF = 1e9;
const ll LINF = 1e18;
// clang-format on

void solve(long long N, long long K, std::vector<long long> A, std::vector<long long> F) {
  SORT(A);
  SORT_DESC(F);
  ll l = -1, r = LINF;
  while (l + 1 < r) {
    ll c = (l + r) / 2;
    bool ok = [&] {
      ll s = 0;
      rep(i, N) {
        s += max(0ll, A[i] - c / F[i]);
      }
      return s <= K;
    }();

    if (ok)
      r = c;
    else
      l = c;
  }
  ANS(r);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> F(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &F[i]);
  }
  solve(N, K, std::move(A), std::move(F));
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    long int A[100000];
    rep(i,100000)A[i]=0;
    unsigned long long sum=0;
    rep(i,N){
        int a;
        cin>>a;
        A[a-1]++;
        sum+=a;
    }
    int Q;
    cin>>Q;
    rep(i,Q){
        int B,C;
        cin>>B>>C;
        sum+=A[B-1]*(C-B);
        A[C-1]+=A[B-1];
        A[B-1]=0;
        cout<<sum<<endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
    for(int i=0;i<N;i++){
      cin >> T.at(i);
    }
  int M;
  cin >> M;
  vector<vector<int>> PX(M,vector<int>(2));
    for(int i=0;i<M;i++){
      cin >> PX.at(i).at(0) >> PX.at(i).at(1);
    }
  int sum=0;
    for(int i=0;i<N;i++){
      sum += T.at(i);
    }
  for(int i=0;i<M;i++){
    int tmp_sum = sum - T.at(PX.at(i).at(0)-1) + PX.at(i).at(1);
    cout << tmp_sum << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        int a[n+1];
        int i,lis[n+1]={0};
        for(i=1; i<=n; i++){
            cin >> a[i];
        }
        lis[1]=1;
        for(i=2; i<=n; i++){
            lis[i]=1;
            if(a[i]<=a[i-1]){
                lis[i]=lis[i-1]+1;
            }
            
        }
        int m=*max_element(lis+1,lis+n+1);
        cout << m-1;
        

}

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

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

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

ll mod = 998244353;

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

  int x;
  cin >> x;

  for(int a = 1;a <= 1000;a++){
    for(int b = -1000;b <= a;b++){
      if(pow(a,5) - pow(b,5) == x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4080
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int X;
  cin >> X;
  int ans = 1;
  for(int b = 2; b <= X; b++){
    //cout << b << endl;
    int v = b * b;
    //cout << v << endl;
    while(true){
      if(v > X){
        break;
      }
      ans = max(ans,v);
      v = v * b;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		map<int, int> Map;
		int temp;
		for(int i = 0; i < N; ++i)
		{
			cin >> temp;
			++Map[temp];
		}
		bool ok = false;
		for(map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
		{
			if(Ite->second > N / 2)
			{
				cout << Ite->first << endl;
				ok = true;
				break;
			}
		}
		if(!ok)
		{
			cout << "NO COLOR" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1940
import java.util.*;

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

      int a = scan.nextInt();
      int b = scan.nextInt();
      int X = scan.nextInt();

      if(a <= X && (a + b) >= X){
         System.out.println("YES");
         }
      else{
          System.out.println("NO");
          }
   }
}


Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
  int N,M;
   int mod=1e9+7;
bool rotti[100010];
vector<    int> memo(100010,-1);
    int sol(   int pos){
  if(memo[pos]>=0)return memo[pos];
  if(pos==0)return 1;
  if(pos==1)return 1;
      int tot=0;
  if(rotti[pos-1]==0)tot+=sol(pos-1);
  if(rotti[pos-2]==0)tot+=sol(pos-2);
  return memo[pos]=tot%mod;
}

int main(){
  //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin>>N>>M;
    int o;
    for(int i=0;i<M;i++){
      cin>>o;
      rotti[o]=1;
    }
    cout<<sol(N);
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<string> s(N);
  for(int i=0; i<N; i++)cin>>s[i];
  sort(s.begin(),s.end());
  int M;cin>>M;
  vector<string> t(M);
  for(int i=0; i<M; i++)cin>>t[i];
  
  int X=0;
  string zs="";
  for(int i=0; i<N; i++){
    int g=1;
    
    if(zs==s[i])continue;
    for(int j=i+1; j<N; j++){
      if(s[i]==s[j])g++;
    }
    for(int j=0; j<M; j++){
      if(s[i]==t[j])g--;
    }
    if(g>0)X=max(X,g);
    zs=s[i];
  }
  cout<<X<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,x,y,m,n,p;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    if(x>=y)
    {
        m=c*x*2;
        n=c*y*2+a*(x-y);
        p=a*x+b*y;
    }
    if(x<y)
    {
        m=c*y*2;
        n=c*x*2+b*(y-x);
        p=a*x+b*y;
    }
    if(m>n)
        m=n;
    if(m>p)
    m=p;
        printf("%d",m);
    return 0;
}

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

struct StNumCnt
{
  StNumCnt() : m_nNum(0), m_nCnt(0) { }

  int m_nNum;
  int m_nCnt;
};

class CGreater_nCnt
{
  public:
    bool operator()(const StNumCnt& lhs, const StNumCnt& rhs)
    {
      return lhs.m_nCnt > rhs.m_nCnt;
    }
};

void fnInput(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int fnMinChangeCnt(const vector<int>& cnrvnNum)
{
  map<int, int> mpNumCntEvn, mpNumCntOdd;

  for (int i = 0; i < cnrvnNum.size(); ++i)
    if ( i % 2 == 0 )
      mpNumCntEvn[ cnrvnNum[i] ]++;
    else
      mpNumCntOdd[ cnrvnNum[i] ]++;

  vector<StNumCnt> voNumCntEvn( mpNumCntEvn.size() ),
                   voNumCntOdd( mpNumCntOdd.size() );

  int n = 0;
  for (pair<int, int> PNumCnt : mpNumCntEvn)
  {
    voNumCntEvn[n].m_nNum   = PNumCnt.first;
    voNumCntEvn[n++].m_nCnt = PNumCnt.second;
  }

  n = 0;
  for (pair<int, int> PNumCnt : mpNumCntOdd)
  {
    voNumCntOdd[n].m_nNum   = PNumCnt.first;
    voNumCntOdd[n++].m_nCnt = PNumCnt.second;
  }

  sort(begin(voNumCntEvn), end(voNumCntEvn), CGreater_nCnt() );
  sort(begin(voNumCntOdd), end(voNumCntOdd), CGreater_nCnt() );

  int nMinChangeCnt = INT_MAX;

  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      if (voNumCntEvn[i].m_nNum != voNumCntOdd[j].m_nNum)
        nMinChangeCnt = 
          min( nMinChangeCnt, 
               (int)cnrvnNum.size() - voNumCntEvn[i].m_nCnt - voNumCntOdd[j].m_nCnt );

  return nMinChangeCnt;
}
  
int main()
{
  vector<int> vnNum;
  
  fnInput(vnNum);
  cout << fnMinChangeCnt(vnNum) << endl;

  return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define sz(a) ((int)a.size())
#define pb push_back

int getbit(int u, int i) {
  return ((u & (1 << i)) != 0);
}

const int maxn = 2e5 + 5;

int n, a[maxn], pre[maxn];
vector<int> has[maxn];

int main() {
  cin >> n;

  rep(i, 0, n) cin >> a[i];

  rep(i, 0, n) {
    rep(j, 0, 20) {
      if (getbit(a[i], j)) {
        has[j].pb(i);
      }
    }
  }

  rep(i, 0, n) pre[i] = -1;

  rep(j, 0, 20) {
    rep(i, 1, sz(has[j])) {
      pre[has[j][i]] = max(pre[has[j][i]], has[j][i - 1]);
    }
  }

  int l = 0;

  long long ans = 0;
  rep(r, 0, n) {
    while (l <= pre[r]) l++;
    long long len = r - l + 1;
    ans += len;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
int stones[101];
int steps[101];

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	int pos = 0;
	for (int i = 0; i < N; ++i) {
		int stone;
		scanf("%d", &stone);
		if (i == 0) {
			steps[pos] = 0;
			stones[pos] = stone;
		}
		else {
			int m = 0x7FFFFFFF;
			for (int j = 1; j <= K && j<=i; j++) {
				int tmp = abs(stone - stones[(pos - j + K) % K]) + steps[(pos - j + K) % K];
				m = min(m, tmp);
			}
			steps[pos] = m;
			stones[pos] = stone;
		}
		pos = (pos + 1) % K;
	}

	printf("%d\n", steps[(pos - 1 + K) % K]);
	system("pause");
	return 0;
}

Measured memory_bytes: 3780
//Structured Program I - Print a Rectangle
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String input;
		
		 while (!(input = in.readLine()).equals("0 0")) {

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

			 int H = Integer.parseInt(HW[0]);
			 int W = Integer.parseInt(HW[1]);

			 for(int i=0;i<H;i++){
				 for(int j=0;j<W;j++){
					 System.out.print("#");
				 }
				 System.out.println();
			 }
			 System.out.println();
			 
		 }

	}
}

Measured memory_bytes: 25904
def solve():
    N, K, *a_l = map(int, open(0).read().split())
    MOD = 10**9+7
    count_a, count_b = 0, 0
    inversion = 0

    for i in range(N):
        for j in range(N):
            if a_l[i] > a_l[j]:
                if i < j:
                    count_a += 1
                count_b += 1

    inversion = count_a * K + count_b * (K * (K - 1)) // 2
    print(inversion%MOD)


if __name__ == '__main__':
    solve()

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

using namespace std;

typedef long long LL;
typedef long double LD;


LL GCD(LL a, LL b) {

  if (a < b) {
    swap(a, b);
  }

  while (b != 0) {
    LL c = a % b;
    a = b;
    b = c;
  }

  return a;

}

int main()
{
  LL N;
  cin >> N;
  vector<LL> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<LL> L(N);
  L[0] = A[0];
  for (int i = 1; i < N; ++i) {
    L[i] = GCD(A[i], L[i - 1]);
  }

  vector<LL> R(N);
  R[N-1] = A[N-1];
  for (int i = N-2; i >= 0; --i) {
    R[i] = GCD(A[i], R[i + 1]);
  }
  vector<LL> M(N);
  M[0]   = R[1];
  M[N-1] = L[N-2];
  for (int i = 1; i < N-1 ; ++i) {
    M[i] = GCD(L[i - 1], R[i + 1]);
  }

  /*
  for (int i = 0; i < N; ++i) {
    cerr << L[i] << " ";
  }
  cerr << endl;
  for (int i = 0; i < N; ++i) {
    cerr << R[i] << " ";
  }
  cerr << endl;

  for (int i = 0; i < N; ++i) {
    cerr << M[i] << " ";
  }
  cerr << endl;
  */

  LL max_val = *max_element(M.begin(), M.end());
  cout << max_val;






  return 0;
}






Measured memory_bytes: 3328
n = int(input())
lst = list(map(int,input().split()))
c = 0
for i in range(n):
  if (lst[i]%2 == 0):
    if (lst[i]%3 != 0 and lst[i]%5 != 0):
      c = 1
if (c == 0):
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 9080
#include <iostream>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    for (int i=k; i<n; i++) {
        if (a[i] > a[i-k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()) {
        int x = s[i] - 'A';
        x = (x + n) % 26;
        putchar('A' + x);
    }
    cout << "\n";
    return 0;
}


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

int main() {
    int R, G, B, N, ans = 0;
    cin >> R >> G >> B >> N;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            if(N-i*R-j*G >= 0 && (N-i*R-j*G) % B == 0) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int a, b, k;
    int i, j;
    
    cin >> a >> b >> k;
    
    if(b - a + 1 <= k * 2) {
        for(i = a; i <= b; i++) {
            cout << i << endl;
        }
    } else {
        for(i = 0; i < k; i++) {
            cout << a + i << endl;
        }
        
        for(j = 0; j < k; j++) {
            cout << b - k + 1 + j << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

ll solve(){
    ll n,k;
    cin>>n>>k;
    ll c=0;
    while(n>0)
    {
        c++;
        n/=k;
    }
    cout<<c<<endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int K = stdIn.nextInt();
		long ans = 1;
		int count = 0;
		
		ArrayList<Long> list = new ArrayList<Long>();
		
		for(int i = 1; i < 10; i ++) {
			list.add((long)i);
		}
		
		int i = 0;
		
		while(list.size() < K) {
			long val = list.get(i);
			if(val % 10 != 0) {
				list.add(val * 10 + val % 10 - 1);
			}
			list.add(val * 10 + val % 10);
			if(val % 10 != 9) {
				list.add(val * 10 + val % 10 + 1);
			}
			i ++;
		}
		
		System.out.println(list.get(K - 1));
		
//		while(true) {
//			if(isLunlun(ans)) {
//				count ++;
//				if(count == K) {
//					break;
//				}
//			}
//			ans ++;
//		}
//		
//		System.out.println(ans);
	}
	
	public static boolean isLunlun(long num) {
		boolean lunlun = true;
		char[] chArr = Long.toString(num).toCharArray();
		for(int i = 0; i < chArr.length - 1; i ++) {
			if(1 < Math.abs((int)chArr[i] - (int)chArr[i + 1])) {
				lunlun = false;
				break;
			}
		}
		return lunlun;
	}
}

Measured memory_bytes: 25940