akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int n;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    vector<int> p(n);
    vector<int> c;

    int cnt = 0;

    rep(i, 0, n)
    {
        cin >> p[i];
    }
    int i = 0;
    while (1)
    {
        // cout << p[i] << "," << i + 1 << endl;
        if (p[i] == i + 1)
        {
            cnt++;
            i++;
        }
        i++;
        if (i >= n)
            break;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define modulo 924844033
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000




int main(){
	
	int N;
	cin>>N;
	
	vector<long long> a(N);
	for(int i=0;i<N;i++)cin>>a[i];
	
	vector<vector<long long>> dp(N+1,vector<long long>(N+1,0));
	
	for(int j=1;j<=N;j++){
		for(int i=0;i<N;i++){
			if(i+j>N)continue;
			if(j%2==N%2){
				dp[i][j] = max(dp[i][j-1]+a[i+j-1],dp[i+1][j-1]+a[i]);
			}
			else{
				dp[i][j] = min(dp[i][j-1]-a[i+j-1],dp[i+1][j-1]-a[i]);
			}
		}
	}
	
	cout<<dp[0][N]<<endl;
	
    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,M,V,P;
  cin >> N >> M >> V >> P;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  ll left = P - 1;
  ll right = N;
  while (right - left > 1) {
    ll mid = (left + right) / 2;
    ll sum = 0;
    bool can = true;
    if (A[mid] + M < A[P-1]) {
      can = false;
    }
    for (int i = 0; i < N; i++) {
      if (i <= P-2) {
        sum += M;
      } else if (P-1 <= i && i < mid) {
        sum += A[mid] + M - A[i];
      } else {
        sum += M;
      }
    }
    if (sum >= M * V && can) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << right << endl;
  return 0;
}

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



int main()
{
    ll n;
    cin>>n;
    vector<ll>v(n);
    vector<ll>dp(n+1,-1);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(ll i=2;i<n;i++)
    {
        dp[i]=min((abs(v[i]-v[i-1])+dp[i-1]),(abs(v[i]-v[i-2])+dp[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 4836
def solve():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    ancilla = [N] * 2001
    for i in range(2001):
        for j in range(N):
            if L[j] > i:
                ancilla[i] = j
                break

    ans = 0
    for i in range(N-1):
        for j in range(i+1,N):
            x = L[i] + L[j]
            tmp = ancilla[x-1] - (j+1)
            if tmp > 0:
                ans += tmp

    print(ans)

solve()

Measured memory_bytes: 41452
#include<bits/stdc++.h>
using namespace std;
double x[10],y[10],ans=0,n_=1;
int n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        n_*=i;
        cin>>x[i]>>y[i];
    }
    double k=1;
    for(int i=1;i<=n-2;i++)
        k*=i;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            double temp=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            ans+=(temp*=2.0*(n-1)*k);
        }
    }
    ans/=n_;
    cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 3844
/*
 * 0305.cc: Yuekis' Audio Room
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int DIST = 100;
const int DEG = 30;
const int N = 5;
const int M = 7;

/* typedef */

/* global variables */

/* subroutines */

inline int pt(int r, int t) { return (t / DEG) * N + r / DIST; }

/* main */

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

  while (n--) {
    int ri, ti;
    cin >> ri >> ti;

    int t0 = (ti / DEG) * DEG, t1 = t0 + DEG;
    int r0 = (ri / DIST) * DIST, r1 = r0 + DIST;

    if (ri == r0 && ti == t0)
      printf("%d\n", pt(ri, ti));
    else if (ri == r0)
      printf("%d %d\n", pt(ri, t0), pt(ri, t1));
    else if (ti == t0)
      printf("%d %d\n", pt(r0, ti), pt(r1, ti));
    else
      printf("%d %d %d %d\n", pt(r0, t0), pt(r1, t0), pt(r0, t1), pt(r1, t1));
  }
  return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define li long 
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
void optimize()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll power(ll x, ll y, ll p) 
{ 
   ll res = 1;       
  
    x = x % p;   
  
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = (res*x) % p; 
  
        
        y = y>>1;  
        x = (x*x) % p;   
    } 
    return res; 
} 
long long gcd(long long a, long long b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
long long lcm(long long a, long long b)  
{  
    return (a*b)/gcd(a, b);  
}  
void test_case()
{
    long long a,b;
    cin>>a>>b;
    cout<<lcm(a,b);
}

int main()
{
	optimize();
	test_case();
}

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

int dx[4] = {0,1,0,-1};
int dy[4] = {-1,0,1,0};
int n;

void debug(vector<string> m){
	for(int y=0 ; y < n ; y++ ){
		for(int x=0 ; x < n ; x++ ){
			cout << m[y][x];
		}
		cout << endl;
	}
}

void solve(){
	vector<string> m(n);
	for(int y=0 ; y < n ; y++ ){
		for(int x=0 ; x < n ; x++ ){
			m[y].push_back(' ');
		}
	}
	int x = 0, y = n-1, d=0;
	m[y][x] = '#';
	int cnt=0;
	while( cnt < 4 ){
		int mx, my;
		bool flag = false;
		for(int i=-1 ; i <= 1 ; i++ ){
			mx = x + dx[d%4];
			my = y + dy[d%4];
			mx = mx + dx[(d-i+4)%4];
			my = my + dy[(d-i+4)%4];
			if( mx >= 0 && my >= 0 && mx < n && my < n && m[my][mx] == '#' ){
				flag = true;
			}
		}
		if( flag ){
			d = (d + 1) % 4;
			cnt++;
			continue;
		}
		
		mx = x + dx[d%4];
		my = y + dy[d%4];
		if( mx < 0 || my < 0 || mx >= n || my >= n ){
			d = (d + 1) % 4;
			cnt++;
			continue;
		}
		m[my][mx] = '#';
		x = mx;
		y = my;
		cnt = 0;
	}
	for(int y=0 ; y < n ; y++ ){
		cout << m[y] << endl;
	}
}

int main(){
	int d;
	cin >> d;
	for(int t=0 ; t < d ; t++ ){
		cin >> n;
		solve();
		if( t != d-1 ){
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
while 1:
    n,m=map(int,input().split())
    if n==0:break
    c,now=1,0
    f=[int(input()) for _ in range(n)]
    d=[int(input()) for _ in range(m)]
    for i in d:
        now+= n if now+i>=n-1 else i+f[now+i]
        if now>=n:break
        c+=1
    print(c)

Measured memory_bytes: 7592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    cout << (a == b ? "EQUAL" : (a.size() < b.size() || (a.size() == b.size() && a < b)) ? "LESS" : "GREATER") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] odd = in.next().toCharArray();
            char[] even = in.next().toCharArray();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < Math.max(odd.length, even.length); ++i) {
                if (i < odd.length) sb.append(odd[i]);
                if (i < even.length) sb.append(even[i]);
            }
            out.println(new String(sb));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

ll t[200010] = {};


int main(void)
{
	ll n, x, k,res = 0,ans = 0;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> x;
		t[x]++;
	}



	for (int i = 1; i <= n; i++) {
		if (t[i] != 0) {
			res++;
		}
	}

	res = std::max(0LL, res - k);

	sort(t,t+200010);

	for (int i = 0; i < 200010; i++) {
		if (t[i] != 0 && res > 0) {
			res--;
			ans += t[i];
		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int h, w;
    cin >> h >> w;
    int cnt = 0;
    vector<vector<char>> d(h, vector<char>(w));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> d[i][j];
            if(d[i][j] == '#') cnt++;
        }
    }

    int x = 0, y = 0;
    int ans = d[x][y] == '#';
    while(true)
    {
        bool flag = false;
        if(x < h-1 && d[x+1][y] == '#')
        {
            flag = true;
            x++;
            ans++;
        }
        else if(y < w-1 && d[x][y+1] == '#')
        {
            flag = true;
            y++;
            ans++;
        }
        if(!flag) break;
    }
    if(ans == cnt) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  ll res = 0;
  while(n--){
    ll a;cin>>a;
    while(a%2==0){
      a/=2;
      res++;
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
map <int ,int> mpa,mpb;

int a[100];

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

int bubbleSort(int n){
  int cnt=0;
  int flag=1;
  int v=0;
  while(flag){
    int i=0;
    flag=0;
    for(int j=n-1;i+1<=j;j--){
      if(a[j]<a[j-1]){
        v=a[j];
        a[j]=a[j-1];
        a[j-1]=v;
        cnt++;
        flag=1;
      }
    }
    i++;
  }
  return cnt;
}

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

  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int ans = bubbleSort(N);
  trace(N);
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

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

int main(){
  int c[26];
  string s;

  cin >> s;
  for(int i=0;i<26;i++)c[i] = 0;
  for(int i=0;i<(int)s.size();i++)c[s[i]-'a']++;

  int f = 0;
  int n = 0;
  for(int i=0;i<26;i++){
    if(c[i]&1){
      f++; c[i]--;
    }
    n += c[i]/2;
  }

  if(f>1){
    cout << 0 << endl;
    return 0;
  }

  vector<ll> u;
  for(int i=2;i<=n;i++)u.push_back(i);

  for(int i=0;i<26;i++){
    for(int j=2;j<=c[i]/2;j++){
      ll tmp = j;
      for(int k=0;k<(int)u.size();k++){
	if(tmp==1)break;
	ll g = gcd(tmp,u[k]);
	tmp /= g;
	u[k] /= g;
      }
    }
  }

  ll ans = 1LL;
  for(int i=0;i<(int)u.size();i++)ans *= u[i];
  cout << ans << endl;
}

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

int main() {
  int r;
  cin>>r;
  if (r<1200) {
    cout<<"ABC"<<endl;
  }
  else if (r<2800) {
    cout<<"ARC"<<endl;
  }
  else {
    cout<<"AGC"<<endl;
  }
  
}


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

using namespace std;

string S, T, U;
int A, B;

int main() {
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(U==S) A--;
  if(U==T) B--;
  cout << A << " " << B;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,m;cin >> n >> m;
	if(n%2 == 1){
		for(int a = 1,b = n-1;a < b&&m;a++,b--,m--){
			cout << a << " " << b << endl;
		}
	}
	else{
		int l,r;
		for(l = 1,r =n-1; l < r && r-l> n/2 &&m;l++,r--,m--){
			cout << l << " " << r << endl;
		}
		r--;
		for(;l < r && m;l++,r--,m--){
			cout << l << " " << r << endl;
		}
	}
	return 0;
}

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

int main() {
    long int A, B, C, K;
    long int value = 0;

    scanf("%ld %ld %ld %ld", &A, &B, &C, &K);

          for (int i = 0; i < A; i++) {
              if (K > 0) {
                  value++;
                  K--;
              }
              else break;
              //printf("value = %ld K = %ld\n", value, K);
          }
          for (int i = 0; i < B; i++) {
              if (K > 0) {
              value = value;
              K--;
              }
              else break;
              //printf("value = %ld K = %ld\n", value, K);
          }
          for (int i = 0; i < C; i++) {
              if (K > 0) {
                  value--;
                  K--;
              }
              else break;
              //printf("value = %ld K = %ld\n", value, K);
          }

    printf("%ld\n", value);

    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,m,k;
char p[]="RGBY";
int op[2333][2333];
void sett(int x,int y,int c)
{
	if(x>=1&&x<=n&&y>=1&&y<=m) op[x][y]=c;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	if(k&1)
	{
	for(int i=0;i<n;++i,puts(""))
		for(int j=0;j<m;++j)
			putchar(p[(i+j)&1]);
	return 0;
	}
	if(k==2)
	{
	k=k/2;
	for(int i=0;i<n;++i,puts(""))
		for(int j=0;j<m;++j)
		{
			int fj=j%4;
			putchar(p[(((i/k)%2+(i/k)/2%2)%2*2+fj)%4]);
		}
	return 0;
	}
	int hk=k/2;
	int l=1; int h=k-1;
	for(int i=-h-h,j=0;i<=n+k;i+=k/2,++j)
	{
		int pl=(j&1)?(-k/2):0;
		int p=j%2*2+j/2%2;
		for(int s=pl;s<=m;s+=k)
		{
			p^=1;
			for(int r=-k/2+1;r<=k/2-1;++r)
			{
				int w=k-abs(r)*2,b=abs(r)+s;
				for(int ss=b;ss<=b+w-1;++ss)
					sett(i+r,ss,p);
			}
		}
	}
	for(int i=1;i<=n;++i,puts(""))
		for(int j=1;j<=m;++j)
			putchar(p[op[i][j]]);
}


Measured memory_bytes: 5888
S = input()
if 'N' in S and 'S' not in S:
    print('No')
    exit()
if 'S' in S and 'N' not in S:
    print('No')
    exit()
if 'E' in S and 'W' not in S:
    print('No')
    exit()
if 'W' in S and 'E' not in S:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 38256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main{
    Scanner scan = new Scanner(System.in);
    int N,M;
    int p[];
    String s[];
    boolean AC[];
    int WA[];
    int penalty[];

    Main(){
        N = scan.nextInt();
        M = scan.nextInt();
        p = new int[M];
        s = new String[M];
        AC = new boolean[N];
        WA = new int[N];
        penalty = new int[N];

        int acs=0;
        for(int i=0; i<N; i++){
            AC[i] = false;
            WA[i] = 0;
            penalty[i] = 0;
        }

        for(int i=0; i<M; i++){
            p[i] = scan.nextInt();
            s[i] = scan.next();
        }
        for(int i=0; i<M; i++){
            if(s[i].equals("WA")){
                WA[p[i]-1] += 1;
            }else{
                if(!AC[p[i]-1]){
                    AC[p[i]-1] = true;
                    acs += 1;
                    penalty[p[i]-1] += WA[p[i]-1];
                }
            }


        }
        
        int penaltys = 0;
        for(int i=0; i<N; i++){
            penaltys += penalty[i];
            //System.out.println(penalty[i]);
        }

        System.out.println(acs+" "+penaltys);


    }

    public static void main(String[] args){
        new Main();
    }
}

Measured memory_bytes: 70320
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long count = 0l;
        long diffbc = Math.min(b, c);
        b -= diffbc;
        c -= diffbc;
        count += 2 * diffbc;
        if (c == 0) {
            count += b;
        } else {
            long diffac = Math.min(a, c);
            count += diffac;
            if (c > a) {
                count += 1;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 21844
N, L = map(int, input().split())
apple = [0]*N
for i in range(N):
  apple[i] = L+i
sum = sum(apple)  
ans = float("INF")
k = -1
for j in range(N):
  sub = abs(sum - (sum - apple[j]))
  if ans > sub:
    ans = sub
    k = j
print(sum - apple[k])

Measured memory_bytes: 3064
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

const int MAX = 100000;
class shuturyoku_unko {
public:
	char C[MAX * 5];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 5) {
				C[i * 5 + 4 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;

const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(ll A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (A >= 100000) {
		if (A >= 1000000000) dig = 5;
		else if (A >= 100000000) dig = 4;
		else if (A >= 10000000) dig = 3;
		else if (A >= 1000000) dig = 2;
		memcpy(di + dig, f.C + A % 100000 * 5, 5);
		A /= 100000;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += 5 + dig;
	}
	else {
		if (A >= 10000) dig = 5;
		else if (A >= 1000) dig = 4;
		else if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += dig;
	}
	*di++ = ' ';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int kei = 0;
	rep(i, N) {
		A[i] = getint();
		kei ^= A[i];
	}
	rep(i, N) putint(kei ^ A[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                if (CheckString(input)) count++;
            }
            Console.WriteLine(count);
        }

        static bool CheckString(string txt)
        {
            int len = txt.Length;
            int n = len / 2;

            for (int i = 0; i < n; i++)
            {
                if (txt[i] != txt[len - 1 - i]) return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  ll len = s.size();
  vector<ll> sum(len);
  ll cnt = 0;
  for(ll i = 1; i < len; i++){
    if(s[i] == 'C' && s[i-1] == 'A') cnt++;
    sum[i] = cnt;
  }

  vector<ll> ans(q);
  for(ll i = 0; i < q; i++){
    ll l, r;
    cin >> l >> r;
    l--, r--;
    ans[i] = sum[r] - sum[l];
  }

  for(auto i : ans) cout << i << endl;
  return 0;
}

Measured memory_bytes: 2640
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)

const int MX = 1005;
const int MM = 1000000007;

int N, M;
ll dist[MX][MX];
vector<t3> E;

struct UF{
	int t[MX];
	int find(int x){ return t[x] ? t[x] = find(t[x]): x; }
	int merge(int a, int b){
		a = find(a), b = find(b);
		return a == b ? 0 : (t[a] = b, 1);
	}
}uf;

vector<pii> T[MX];

ll pw2[MX*2];

int path_mn(int a, int b, int p = -1){
	if(a == b) return 0;
	for(pii c : T[a]){
		if(c.second == p) continue;
		int v = path_mn(c.second, b, a);
		if( v != -1) return max(v, c.first);
	}
	return -1;
}

int main()
{
	pw2[0] = 1;
	for(int i = 1; i < MX*2; i++) pw2[i] = pw2[i-1] * 2 % MM;
	ll X;
	scanf("%d%d%lld", &N, &M, &X);
	for(int i = 1; i <= M; i++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		E.emplace_back(c, a, b);
	}
	sort(E.begin(), E.end());
	ll tot = 0, cnt = 0;
	for(int i = 0, j = 0; i < E.size(); i++){
		for(; j < E.size() && get<0>(E[i]) == get<0>(E[j]); j++){
			int a, b, c;
			tie(c, a, b) = E[j];
			if(uf.find(a) != uf.find(b)) cnt++;
		}
		for(int k = i; k < j; k++){
			int a, b, c;
			tie(c, a, b) = E[k];
			if(!uf.merge(a, b)) continue;
			tot += c;
			T[a].emplace_back(c, b);
			T[b].emplace_back(c, a);
		}
	}
	if(tot == X){
		ll ans = pw2[M] - pw2[M-cnt] * 2;
		ans = (ans % MM + MM) % MM;
		return !printf("%lld\n", ans);
	}
	ll fr = 0, ct = 0;
	for(auto e : E){
		int a, b, c;
		tie(c, a, b) = e;
		int v = path_mn(a, b);
		if( tot - v + c == X ) ct++;
		else if(tot - v + c > X) fr++;
	}
	ll ans = (pw2[fr + ct] - pw2[fr]) * 2;
	ans = (ans % MM + MM) % MM;
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
int l,r,d;
cin>>l>>r>>d;

int a,b;

if (l%d==0){
    a=l/d-1;
}else
{
    a=l/d;
}

b=r/d;

cout<<b-a<<endl;


}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define forp(x,a,b) for(int x=a; x<b; x++)
#define forn(x,a,b) for(int x=a; x>b; x--)
#define SZ(a) ((int)(a).size())
#define pb push_back
#define vec(x) vector<x>
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
using namespace std;
typedef long long ll;


int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin>>s>>t;
    int n=s.size(),k=0;
    forp(i,0,n){if(s[i]!=t[i]){k++;}}
    cout<<k;
    
  
    
    return 0;}

Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int MAXPRICE = 1000000;

VI getPrimes()
{
	VI res( MAXPRICE + 1, true );
	res[0] = res[1] = false;

	REP( i, 2, MAXPRICE + 1 )
	{
		if ( !res[i] )
		{
			continue;
		}

		for ( int j = 2; i * j <= MAXPRICE; j++ )
		{
			res[ i * j ] = false;
		}
	}

	return res;
}

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

	VI isPrime = getPrimes();

	while ( true )
	{
		int n, x;
		cin >> n >> x;

		if ( !( n | x ) )
		{
			break;
		}

		VI ps( n );

		EACH( p, ps )
		{
			cin >> p;
		}

		VI dp( x + 1, false );
		dp[0] = true;

		REP( i, 0, n )
		{
			REP( j, 0, x + 1 )
			{
				if ( ps[i] <= j )
				{
					dp[j] |= dp[ j - ps[i] ];
				}
			}
		}

		int res = -1;

		REP( i, 0, dp.size() )
		{
			if ( isPrime[i] && dp[i] )
			{
				res = i;
			}
		}

		if ( res == -1 )
		{
			cout << "NA";
		}
		else
		{
			cout << res;
		}
		cout << endl;
	}

	return 0;
}

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

void solve() {
    ll H;
    cin >> H;
    int c = 0;
    while(1 < H) {
        H /= 2;
        c++;
    }
    ll x = 0;
    for (int i = 0; i < c+1; ++i) {
        x += pow(2, i);
    }
    cout << x << endl;
}

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


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

using std::cerr;
using std::endl;

typedef long long ll;

inline ll rd(){
  ll x; scanf("%lld",&x);
  return x;
}

const int N=1e5+233;

int n;
ll D[N],S[N];
std::vector<std::pair<int,int>>ans;
std::map<ll,int>map;
std::vector<int> T[N];

ll dfs(int x,int fa,int dis){
  ll ret=dis;
  for(int y:T[x]) if(y!=fa)
    ret+=dfs(y,x,dis+1);
  return ret;
}

int main(){
  //freopen("data","r",stdin);
  n=rd();
  for(int i=1;i<=n;++i){
    D[i]=rd();
    S[i]=1;
    map[-D[i]]=i;
  }
  while(!map.empty()){
    if(map.size()==1)
      break;
    int x=map.begin()->second;
    map.erase(map.begin());
    std::map<ll,int>::iterator it;
    it=map.find(-(D[x]-n+2*S[x]));
    if(it==map.end()){
      puts("-1");
      return 0;
    }
    S[it->second]+=S[x];
    ans.push_back({x,it->second});
    T[x].push_back(it->second);
    T[it->second].push_back(x);
  }
  int root=map.begin()->second;
  if(dfs(root,0,0)!=D[root]){
    puts("-1");
    return 0;
  }
  for(int i=0;i<n-1;++i)
    printf("%d %d\n",ans[i].first,ans[i].second);
  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll B = TEN(9);

int cnt[50][20];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    ll ans = 0;

    rep(i, N) {
        string s;
        cin >> s;
        int x, y = 0;
        int d = 0;
        if (s.find('.') == string::npos) {
            x = stoi(s);
        } else {
            int p = s.find('.');
            auto t = s.substr(0, p);
            auto q = s.substr(p + 1);
            d = q.size();
            x = stoi(t);
            y = stoi(q);
        }

        ll v = x * B + y * TEN(9 - d);
        debug(x, y, v);
        ll c2 = 0, c5 = 0;
        while (v % 2 == 0) {
            c2++;
            v /= 2;
        }
        while (v % 5 == 0) {
            c5++;
            v /= 5;
        }
        debug(c2, c5);
        rep(j, 50) {
            rep(k, 20) {
                if (j + c2 >= 18 && k + c5 >= 18) {
                    ans += cnt[j][k];
                }
            }
        }
        cnt[c2][c5]++;
    }
    cout << ans << endl;

    return 0;
}

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

int main(int argc, char const *argv[]) {
  int n, k;
  std::cin >> n >> k;

  std::vector<long> h;

  for (size_t i = 0; i < n; i++) {
    long tmp;
    std::cin >> tmp;
    h.push_back(tmp);
  }

  std::sort(h.begin(), h.end());

  long diff = LONG_MAX;
  for (size_t i = 0; i < h.size()-k+1; i++) {
    if (h.at(i+k-1) - h.at(i) < diff) diff = h.at(i+k-1) - h.at(i); 
  }

  std::cout << diff << '\n';
  return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<long> a(N);
    long cash = 1000;
    long n = 0;
    for (int i=0; i<N; i++){
        cin >> a[i];
    }
    if (a[0] < a[1]){
        n = n + cash / a[0];
        cash = cash - a[0] * n;
    }
    for (int i=1; i<N-1; i++){
        if (a[i-1] < a[i] and a[i] >= a[i+1]){
            // short 
            cash = cash + n * a[i];
            n = 0;
        }
        if (a[i-1] > a[i] and a[i] <= a[i+1]){
            // long
            if (n == 0){
                n = cash / a[i];
                cash = cash - a[i] * n;
            }
        }
        if (a[i-1] = a[i] and a[i] < a[i+1]){
            // long
            if (n == 0){
                n = cash / a[i];
                cash = cash - a[i] * n;
            }
        }
        if (a[i-1] = a[i] and a[i] > a[i+1]){
            // short
            cash = cash + n * a[i];
            n = 0;
        }
    }
    cash = cash + n * a[N-1];
    cout << cash << endl;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
Alst = list(map(int, input().split()))
l = len(Alst)
Blst = [0]*l
k = 0
ans = 0
for i in range(l-1, 0, -1):
    k = (k + Alst[i])%(10**9 + 7)
    Blst[i] = k

for j in range(l-1):
    ans = (ans + Alst[j] * Blst[j+1])%(10**9 + 7)

print(ans)

Measured memory_bytes: 31548
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;


void print() {
    cout << endl;
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}
 
template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}
 
template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
	vector<int> vec(5);
	int k;
	rep(i,5)cin >> vec[i];
	cin >> k;
	bool ok = true;
	rep(i,5)rep(j,5){
		if(abs(vec[i] - vec[j]) > k)ok = false;
	}
	cout << (ok ? "Yay!" : ":(") << endl;
}

    

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static int head1 = 0;
	public static int head2 = 0;
	public static int tail = 0;
	public static String[] queue1 = new String[1000000];
	public static int[] queue2 = new int[1000000];
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int q = stdIn.nextInt();
		
		for (int i = 0; i < n; i++) {
			String a = stdIn.next();
			int b = stdIn.nextInt();
			enqueue(a, b);
		}
		
		int time = 0;
		while (head1 != tail) {
			String a = strDequeue();
			int b = intDequeue();
			if (b <= q) {
				time += b;
				System.out.println(a +" "+ time);
			}
			else {
				time += q;
				b -= q;
				enqueue(a, b);
			}
		}
	}
	
	public static void enqueue(String x, int y) {
		queue1[tail] = x;
		queue2[tail] = y;
		tail++;
	}
	
	public static String strDequeue() {
		return queue1[head1++];
	}
	
	public static int intDequeue() {
		return queue2[head2++];
	}
}

Measured memory_bytes: 85552
#include<iostream>
#include<stdio.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<math.h>
#include<queue>
#include<stack>
#include<ctime>
#include<set>
using namespace std ;

int n , k ;
string a ;



void input ( ) {
    cin >> n >> k ;
    cin >> a ;
    a = 'W' + a + 'W' ;
}

void solve ( ) {
    int init = 0 ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        if ( a[ i ] == a[ i - 1 ] ) { ++ init ; }
    }
    k *= 2 ;
    for ( int i = 2 ; i <= n ; ++ i ) {
        if ( a[ i ] != a[ i - 1 ] && k > 0 ) {
            ++ init ;
            -- k ;
        }
    }
    printf ( "%d\n" , init ) ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


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

int main() {
    int s;
    cin >> s;
    int fir = s / 100;
    int sec = s % 100;
    /*
    string s;
    cin >> s;
    int fir = (s[0] - '0') * 10 + s[1] - '0';
    int sec = (s[2] - '0') * 10 + s[3] - '0';
    */
   if (fir >= 1 && fir <= 12) {
       if (sec >= 1 && sec <= 12) {
           cout << "AMBIGUOUS" << endl;
       }
       else {
           cout << "MMYY" << endl;
       }
   }
   else {
       if (sec >= 1 && sec <= 12) {
           cout << "YYMM" << endl;
       }
       else {
           cout << "NA" <<endl;
       }
   }
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(void)
{
    int num, i, j, a, count=0;

    scanf("%d", &num);
    int arg[num+1];

    for(i=1; i<=num; i++) {
        scanf("%d",&a);
        arg[i] = a;
    }
    
    for(j=1; j<=num; j++) {
        if (arg[j] % 2 == 1 && j % 2 == 1) {
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> ps(N+1, 0);
    ll ans = 0;
    for ( ll i = 1; i <= N; i++ ) {
        for ( ll k = 1; k*i <= N; k++ ) {
            ans += i*k;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 81332
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

void solve(){
    bool visit[50005];
    rep(50005) visit[i]=false;
    ll n,k; cin>>n>>k;
    vector<ll> p(n),c(n); rep(n) cin>>p[i]; rep(n) cin>>c[i];
    rep(n) p[i]--;
    vector<vector<ll>> arr;
//    for(auto i:p) cout<<i<<" "; cout<<endl;
    rep(n) if(!visit[i]){
        visit[i]=true; vector<ll> rw(1,i); ll ti=p[i];
        while(ti!=i) {
            visit[ti]=true;
//            cout<<ti<<" "<<endl;
            rw.append(ti); ti=p[ti];
        }
        arr.append(rw);
    }
    rep(arr.size()) jrep(arr[i].size()) arr[i][j]=c[arr[i][j]];
    ll mx = *max_element(all(c));
    for(auto a:arr){ 
//        for(auto j:a) cout<<j<<" "; cout<<" -- "<<endl;

        ll tn = a.size();
        ll tms = a[0];
        rep(tn){
            ll tk = k;
            ll csu = a[i]; ll in=i; tk--;
            ll su = accumulate(all(a),(ll)0);
            ll ms = max(su*(tk/tn) + csu, csu);
            jrep(tn-1){
                in++; tk--; in%=tn; csu+=a[in];
                if(tk<0) break;
                ms = max({ms,su*(tk/tn) + csu, csu});
//                cout<<tk<<" "<<su*(tk/tn) + csu<<"  "<<i<<" = "<<ms<<endl;
            }
            tms = max(tms,ms);
        }
        mx = max(mx,tms);
        //cout<<tms<<endl;
//        cout<<" -------------- \n";
    }
    cout<<mx<<endl;
}
 
int main(){
    ffast
    ll t=1;
    //cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 3840
q,h,s,d = map(int,input().split())
N = int(input())
qp,hp,dp = q*4,h*2,d//2
i = 0
ans = 0
if dp<hp and dp<qp and dp<s:
    ans = d*(N//2)
    N %= 2
ans += min(s,min(hp,qp))*N
print(int(ans))


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

vector<pair<int, int> > vec;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int k;
  int n; cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a, b; cin >> a >> b;
    vec.push_back({a, b});
  }
  sort(vec.begin(), vec.end());
  int ans = -1;
  for (int i = 0; i < n; i++) {
    k -= vec[i].second;
    if (k <= 0) {
      ans = vec[i].first;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
#define D 80*160
bitset<D*2>dp[89][89];

int main(){
  int h,w;
  int a[89][89];
  cin>>h>>w;
  rep(i,h)rep(j,w){
    cin>>a[i][j];
  }
  rep(i,h)rep(j,w){
    int x;
    cin>>x;
    a[i][j]=abs(a[i][j]-x);
  }

  dp[0][0][D+a[0][0]]=1;
  dp[0][0][D-a[0][0]]=1;
  rep(i,h)rep(j,w){
    if(i){
      dp[i][j]|=dp[i-1][j]<<a[i][j];
      dp[i][j]|=dp[i-1][j]>>a[i][j];
    }
    if(j){
      dp[i][j]|=dp[i][j-1]<<a[i][j];
      dp[i][j]|=dp[i][j-1]>>a[i][j];
    }
  }

  int ans=INF;
  rep(i,D*2){
    if(dp[h-1][w-1][i]){
      ans=min(ans,abs(i-D));
    }
  }

  cout<<ans<<endl;

  return(0);
}


Measured memory_bytes: 22656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if (A + B < C + D)
    cout << "Right" << endl;
  else if (A + B == C + D)
    cout << "Balanced" << endl;
  
    else if (A + B > C + D)
      cout << "Left" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll mpow(ll x, ll n) { ll y = 1; for (; n; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2); for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return k < 0 || k > n ? 0 : fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} C(1e5);

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));

    map<int, int> same, small;
    rep(i, N) {
        if (same[A[i]] == 0) {
            small[A[i]] = i;
        }
        same[A[i]]++;

    }

    ll ans = 0;
    for (int i = 0, j; i < N; i = j) {
        for (j = i + 1; j < N; ++j) {
            if (A[j] != A[i]) break;
        }

        int e = same[A[i]], s = small[A[i]], l = N - e - s;
        if (e + s >= K) {
            if (s >= K) {
                ans = (ans + A[i] * (C(e + s, K) - C(s, K) + MOD)) % MOD;
            }
            else {
                ans = (ans + A[i] * C(e + s, K)) % MOD;
            }
        }
        if (e + l >= K) {
            if (l >= K) {
                ans = (ans - A[i] * (C(e + l, K) - C(l, K) + MOD) % MOD + MOD) % MOD;
            }
            else {
                ans = (ans - A[i] * C(e + l, K) % MOD + MOD) % MOD;
            }
        }
    }

    write(ans);
}

Measured memory_bytes: 11264