akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

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

	ll res = 0;

	DESC(H);
	FOR(i, K, N) {
		res += H[i];
	}

	cout << res << "\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd .. 
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(a % b, b);
}

int main(void) {
  int n;
  cin >> n;
  int a[n];
  rep (i, n) cin >> a[i];

  vector<int> R(n + 1, 0), L(n + 1, 0);

  L[0] = a[0];
  R[n - 1] = a[n - 1];
  
  for (int i = 1; i < n; i++) {
    L[i] = gcd(L[i - 1], a[i]);
  }
  
  for (int i = n - 2; i >= 0; i--) {
    R[i] = gcd(R[i + 1], a[i]);
  }
  
  int ans = -1001001001;
  for (int i = 1; i < n - 1; i++) {
    ans = max(ans, gcd(L[i - 1], R[i + 1]));
  }
  ans = max(ans, L[n - 2]);
  ans = max(ans, R[1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include <math.h>
#include <cmath>
using namespace std;
#define ll long long
 
ll a[200050] = {};
ll A[200050] = {};
 
int main()
{
	ll n;
	ll ans = 0;
	cin >> n;
 
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
        a[i] -= i+1;
		A[i] = a[i];
	}
 
	sort(a, a + n);
	ll b;
	if (n % 2 != 0) {
		b = a[(n - 1) / 2];
	}
	else {
		b = (a[n / 2] + a[(n / 2) - 1]) / 2;
	}
 
	// b = b - (n - 1) / 2;
 
	// for (ll i = 0; i < n; i++)
	// {
	// 	ans += abs(A[i] - b);
	// 	b++;
	// }
    for (ll i = 0; i < n; i++){
        ans += abs(A[i] - b);
    }
 
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
	int n, k;
	cin >> n >> k;
	int *a = new int[n];
	int zero = 0;
	for(int i = 0; i < n; i++){
			cin >> a[i];
			if(a[i] == 1)zero = i;
	}
	int mina = 1000000;
	for(int i = 0; i < k; i++){
			int res = 1;
			int ld = max(zero - i, 0);
			int rd = min(zero + k - i - 1, n - 1);
			while(ld > 0){
					ld = ld - k + 1;
					res++;
			}
			while(rd < n - 1){
					rd = rd + k - 1;
					res++;
			}

			if(mina > res)mina = res;
	}
	cout << mina << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
struct Node{
	int key;
	Node *prev,*next;
};

Node *nil;

void init(){
	nil=(Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key){
	Node *x=(Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev= x;
	x->prev = nil;
	nil->next =x; 
}

void deleteFirst(){
	Node *f = nil->next;
	nil->next = f->next;
	f->next->prev = nil;
	free(f);
}

void deleteLast(){
	Node *l = nil->prev;
	l->prev->next = nil;
	nil->prev = l->prev;
	free(l);
}
void deleteNode(int key){
	Node *cur = nil->next;
	while(cur->key != key && cur != nil){
		cur =cur->next;
	}
	if(cur == nil) return;
	cur->prev->next = cur->next;
	cur->next->prev = cur->prev;
	free(cur);
}

int main(){
	init();
	int o,n;
	char s[20];
	scanf("%d",&o);
	getchar();
	while(o--){
		scanf("%s",s);
		if(s[0]=='i'){
			scanf("%d",&n);
			getchar();
			insert(n);
		}
		else if(s[0]=='d'&&s[6]=='F'){
			deleteFirst();
			getchar();
		}
		else if(s[0]=='d'&&s[6]=='L'){
			deleteLast();
			getchar();
		}
		else if(s[0]=='d'){
			scanf("%d",&n);
			getchar();
			deleteNode(n);
		}
	}
	Node *cur=nil->next;
	while(cur != nil){
		printf("%d",cur->key);
		cur = cur->next;
		if(cur != nil) printf(" ");
	}
	printf("\n");
} 


Measured memory_bytes: 33824
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int h,a,i;
cin>>h>>a;
 if((h%a)!=0)
 {
   i=(h/a)+1;
   if(i==0)
     cout<<i+1;
   else
   cout<<i;
 }
  else
    cout<< h/a;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vll vector <ll>
#define fi first
#define se second
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 5e5+100;
const ll INF = 1e9;
const ll kek=998244353;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int cnt=0;
    for (int i=0;i<s.size()/2;i++)
    {
        if (s[i]!=s[s.size()-1-i])
            cnt++;
    }
    cout<<cnt;
}








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

using namespace std;
int arr[200005];

bool isvalid(int m,int n,int k)
{
	if(m==0) return false;
	long long total=0;
	for(int i=0;i<n;i++)
	{
		total+=(arr[i])/m;
		if(arr[i]%m==0) total--;
	}

	if(total<=k) return true;
	return false;
}

void solve(int n,int k)
{
	int i=0,j=1000000001;
	while(i<j)
	{
		int mid=(i+j)/2;
		if(isvalid(mid,n,k))
			j=mid;

		else
			i=mid+1;
	}

	cout<<i;
}

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

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

	solve(n,k);

	return 0;
}

Measured memory_bytes: 4400
n, k = map(int, input().split())
res = 0
for b in range(k+1, n+1):
#     print("-"*10)
    if n%b == 0:
        res += (n//b) * (b-k)
#         print((n//b) * (b-k))
    else:
        res += n//b*(b-k) + max(n%b - k  + 1, 0)
        if k == 0:
            res -= 1
#         print(b, n//b*(b-k), max(n%b - k + 1, 0))
print(res)

Measured memory_bytes: 3060
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

st = sorted(p)
x = list(itertools.permutations(st, n))

num1 = x.index(tuple(p))
num2 = x.index(tuple(q))
print(abs(num1 - num2))

Measured memory_bytes: 8052
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

template <typename QvQ> inline QvQ Min(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max(QvQ a,QvQ b){if(a>b) return a;return b;}

#define inf 2147483647
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f

#define ll long long
#define rei register int
#define inv inline void
#define ull unsigned long long
#define il inline

#define bl putchar(' ')
#define ed putchar('\n')
#define test cout<<"this:" 

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

template <typename QvQ>inv read(QvQ &x){
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define int long long
const int maxn=3e6+5;
int n;
signed main()
{
	read(n); int ans=0;
	for(rei i=1;i<=n;++i){
		if(n-i<=i) break;
		++ans;
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

#define MAX_V 100000

typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    int count[MAX_V + 1][2];
    for (int i = 0; i <= MAX_V; i++) {
        count[i][0] = 0;
        count[i][1] = 0;
    }
    
    for (int i = 0; i < n; i++) {
        int temp;
        scanf("%d", &temp);
        count[temp][i % 2]++;
    }

    vector<P> list[2];
    for (int i = 0; i <= MAX_V; i++) {
        P temp0;
        temp0.second = i;
        temp0.first = count[i][0];
        list[0].push_back(temp0);
        P temp1;
        temp1.second = i;
        temp1.first = count[i][1];
        list[1].push_back(temp1);
    }

    sort(list[0].begin(), list[0].end(), greater<P>());
    sort(list[1].begin(), list[1].end(), greater<P>());

    int cost = 0;
    if (list[0][0].second == list[1][0].second) {
        cost = min(
            n - (list[0][0].first + list[1][1].first),
            n - (list[0][1].first + list[1][0].first)
        );
    } else {
        cost = n - (list[0][0].first + list[1][0].first);
    }
    cout << cost << endl;
    
    return 0;
}

Measured memory_bytes: 2804
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

ll vs[100000+10];
int n;

int visited[100000+10];
// bool isOK1(ll ab, int i) {
//   ll a = n-1 - ab*i;
//   ll b = a - ab;
//   if(a <= 0 || b <= 0) return false;
// }

// int visited2[100000+10];
// int counter2;
// bool isOK2(ll ab, int i) {
//   ++counter2;
//   ll a = n-1 - ab*i;
//   ll b = a - ab;
//   if(a <= 0 || b <= 0) return false;
//   visited2[0] = counter2;
//   for(int pos = 0; ; ) {
//     pos += a;
//     if(pos >= n) return false;
//     if(visited2[pos] == counter2) return false;
//     visited2[pos] = counter2;
//     if(pos == n-1) {
//       return true;
//     }
//     pos -= b;
//     if(pos < 0) return false;
//     if(visited2[pos] == counter2) return false;
//     visited2[pos] = counter2;
//   }
// }

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }

  ll res = 0;
  for(int ab = 1; ab < n-1; ++ab) {
    ll leftSum = 0;
    ll rightSum = 0;
    for(int i = 1; ab*i < n && n-1-ab*i >= 0; ++i) {
      ll a = n-1 - ab*i;
      ll b = a - ab;
      if(a <= 0 || b <= 0) break;
      if(visited[ab*i] == ab) break;
      visited[ab*i] = ab;
      if(visited[n-1-ab*i] == ab) break;
      visited[n-1-ab*i] = ab;
      // bool x1 = isOK1(ab, i);
      // bool x2 = isOK2(ab, i);
      // if(x1 != x2) {
      //   ll a = 
      //   ll b = a - ab;
      //   cerr << "> " << x1 << " " << x2 << " " << ab << " " << i << " " << a << " " << b << " " << ab*i << " " << n-1-ab*i << endl;
      // }
      // if(!x2) break;
      leftSum += vs[ab*i];
      rightSum += vs[n-1-ab*i];
      res = max(res, leftSum + rightSum);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1408
def main():

    N, W = map(int, input().split())

    dp = [[0 for _ in range(W+1)] for _ in range(2)]

    max_v = 0
    for i in range(N):
        w, v = map(int, input().split())
        for j in range(W+1):
            if j - w >= 0:
                dp[(i+1)%2][j] = max(dp[i%2][j], dp[i%2][j-w]+v)
            else:
                dp[(i+1)%2][j] = dp[i%2][j]
        max_v = max(max(dp[(i+1)%2]), max_v)

    return max_v

if __name__ == '__main__':
    print(main())

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = m; i >= l; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 1005;

void Solve(){
    int D;
    cin >> D;
    string t = " Eve";
    string s = "Christmas";
    for(int i = 25; i > D; i--) s += t;
    cout << s;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
    return 0;
}


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

int main() {
	int n, m; cin >> n >> m;
	int a[n][m];
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			cin >> a[i][j];
			--a[i][j];
		}
	}
	bool open[m];
	for(int i = 0; i < m; ++i) open[i] = true;
	int ans = n;
	for(int q = 0; q < m - 1; ++q) {
		int cnt[m] = {};
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m; ++j) {
				if(open[a[i][j]]) {
					++cnt[a[i][j]];
					break;
				}
			}
		}
		int maxi = 0, midx;
		for(int i = 0; i < m; ++i) {
			if(maxi < cnt[i]) {
				maxi = cnt[i];
				midx = i;
			}
		}
		ans = min(ans, maxi);
		open[midx] = false;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5;
const int INF = 1e9;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h,n;
	cin>>h>>n;
	vector<pair<int,int>> spell(n);
	int dp[MAX];
	for (int i = 0; i < MAX; i++) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		cin>>spell[i].first>>spell[i].second;
	}
	int ans = INF;
	for (int i = 1; i <= h + MAX/10; i++) {
		for (auto it : spell){
			if (it.first <= i && dp[i - it.first] != INF) {
				dp[i] = min(dp[i], dp[i - it.first] + it.second);
			}
		}
		if (i >= h) {
			ans = min(ans, dp[i]);
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  while (n >= 1) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	map<int,int> ct;
	for (int i=0; i<n; i++) {
		int k; cin>>k;
		for (int j=0; j<k; j++) {
			int a; cin>>a; ct[a]++;
		}
	}
	int ret=0;
	for (const auto &it : ct)
		if(it.second==n)
			ret++;
	cout<<ret<<"\n";
	return 0;
}

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

N, M = map(int, input().split())

answer_list = [0] * M
prefectures = [0] * (N+1)
data_set = [0] * M

for i in range(M):
	P, Y = map(int, input().split())
	data_set[i] = [P, Y, i]

data_set.sort()

for i in range(M):
	answer = ''
	P, Y, a = data_set[i]
	prefectures[P] += 1

	for j in range(6-len(list(str(P)))):
		answer += '0'

	answer += str(P)

	for k in range(6-len(list(str(prefectures[P])))):
		answer += '0'

	answer += str(prefectures[P])

	answer_list[a] = answer

for i in range(M):
	print(answer_list[i])

Measured memory_bytes: 32132
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
template<typename A,size_t N,typename T>
void Fill(A (&array)[N],const T &val)
{
    std::fill( (T*)array,(T*)(array+N),val );
}
int main(void)
{
    char c;
    cin >> c;
    cout << char(c+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n, a, b;

  cin >> n >> a >> b;

  if((n * a) == b){
      cout << b << endl;
  }
  if((n * a) > b){
      cout << b << endl;
  }
  if((n * a) < b){
      cout << n * a << endl;
  }

}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int b = sc.nextInt();
			int m = sc.nextInt();
			int e = sc.nextInt();
			List<Integer> list2 = new ArrayList<>();
			for (int j = 0; j < b; j++) {
				list2.add(list.get(j));
			}
			for (int j = m; j < e; j++) {
				list2.add(list.get(j));
			}
			for (int j = b; j < m; j++) {
				list2.add(list.get(j));
			}
			for (int j = e; j < list.size(); j++) {
				list2.add(list.get(j));
			}
			list = list2;
		}
		StringBuilder sb = new StringBuilder();
		for (int num : list) {
			sb.append(num + " ");
		}
		String str = sb.toString();
		str = str.substring(0, str.length() - 1);
		System.out.println(str);
	}
}




Measured memory_bytes: 56572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007ll

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)
  int s;
  cin >> s;
  vector<ll> dp(s+1); //
  ll sum = 0;
  for (int i = 3; i <= s; i++) {
    dp[i] = (1 + sum) % MOD;
    sum += dp[i-2]; sum %= MOD;
  }
  cout << dp[s] << endl;
  //for (int i = 0; i <= s; i++) cout << dp[i] << " ";
}



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

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

  vector<int> d(N);
  for (int i = 0; i < N; i++)
    cin >> d.at(i);

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

  cout << d.at(d.size() / 2) - d.at((d.size() / 2) - 1) << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
cnt = [0] * (n + 1)
ans = 0
for i in range(n+1):
    for j in range(1, n+1):
        if i * j > n:
            break
        cnt[i * j] += 1
    ans += i * cnt[i]
print(ans)

Measured memory_bytes: 145908
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
void exgcd(int a,int b,int &x,int &y){
	if(b==0){
		x=1;y=0;return;
	}
	exgcd(b,a%b,y,x);y-=(a/b)*x;
}
int main(){
	int x,y;scanf("%d%d",&x,&y);
	int a,b;exgcd(x,y,a,b);
	cout<<a<<" "<<b<<endl;
	return 0;
}



Measured memory_bytes: 3252
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))



int main(void){
	int i;
	char *s;
	s = calloc(sizeof(char),100002);
	scanf("%s",s);
	i = 1;
	while(*(s + 2) != '\0'){
		if(*s == *(s + 1)){
			printf("%d %d\n", i,i+1);
			return 0;
		}
		if(*s == *(s + 2)){
			printf("%d %d\n", i, i + 2);
			return 0;
		}
		s++;
		i++;
	}
	if(*s == *(s + 1)){
		printf("%d %d\n", i,i+1);
		return 0;
	}
	printf("%d %d\n", -1,-1);

	return 0;
}

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

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

    vector<int> a(n);
    rep (i, n)
        cin >> a[i];

    vector<int> b(n);
    int repCnt = min(k, 1000);
    rep (i, repCnt)
    {
        rep (j, n)
            b[j] = 0;
        rep (j, n)
        {
            int l = max(0, j - a[j]);
            int r = min(n - 1, j + a[j]);
            b[l]++;
            if (r < n - 1)
                b[r + 1]--;
        }
        a[0] = b[0];
        for (int j = 1; j < n; j++)
        {
            b[j] += b[j - 1];
            a[j] = b[j];
        }
    }

    rep (i, n)
        cout << b[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<cmath>
#include<algorithm>
typedef unsigned long long int ll;
using namespace std;
ll limit;
ll A[100005];
int main(){
  int N;
  limit=1000000000000000000;
  cin>>N;
  bool c=false;
  for(int i=0; i<N; i++) cin>>A[i];
  sort(A,A+N);
  ll mult;
  mult=A[0];
  for(int i=1; i<N; i++){
    ll tmp=A[i];
    ll prev=mult;
    mult*=tmp;
    if((tmp!=0 && mult/tmp!=prev) || mult>limit){
      c=true;
    }
  }
  if(c){
    cout<<"-1"<<endl;
    return 0;
  }
  cout<<mult<<endl;
  return 0;
}


Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50,mod=1e9+7;
int n,k,m,a[N],c[N],b[N],J[N],I[N],ans;
int C(int n,int m){return n<m?0:1ll*J[n]*I[m]%mod*I[n-m]%mod;}
int main(){
    // freopen("test.in","r",stdin);
    scanf("%d%d",&n,&k);J[0]=I[0]=I[1]=1;
    for(int i=2;i<=n;i++)I[i]=mod-1ll*mod/i*I[mod%i]%mod;
    for(int i=1;i<=n;i++)J[i]=1ll*J[i-1]*i%mod,I[i]=1ll*I[i-1]*I[i]%mod;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),c[i]=a[i];
    sort(c+1,c+n+1);m=unique(c+1,c+n+1)-c-1;
    for(int i=1;i<=n;i++){
        a[i]=lower_bound(c+1,c+m+1,a[i])-c;
        b[a[i]]++;
    }
    for(int i=1,sum=0;i<=m;i++){
        ans=(ans+1ll*(C(sum+b[i],k)-C(sum,k))*c[i])%mod;
        sum+=b[i];
    }
    for(int i=m,sum=0;i;i--){
        ans=(ans-1ll*(C(sum+b[i],k)-C(sum,k))*c[i])%mod;
        sum+=b[i];
    }
    printf("%d\n",(ans+mod)%mod);
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)

using namespace std;
const int Nmax = 1e5 + 11;

int n, f[Nmax], h[Nmax];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        cin >> h[i];
    }
    f[2] = abs(h[1] - h[2]);
    FOR(i, 3, n) {
        f[i] = f[i - 2] + abs(h[i - 2] - h[i]);
        f[i] = min(f[i], f[i - 1] + abs(h[i - 1] - h[i]));
    }
    cout << f[n];
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void)
{
    double r;
    double pi=3.141592653589;
 
        scanf("%lf",&r);
 
        if(0 < r < 10000)
 
        printf("%f %f\n",pi*r*r,2*pi*r);
 
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 10007;
const ld PI = acosl(-1);

struct dat {
    int L, R, C;
};

bool operator<(dat &a, dat &b) {
    return a.L < b.L;
}

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

    int N, M;
    cin >> N >> M;
    vector<dat> v(M);
    for (int i = 0; i < M; ++i) {
        cin >> v[i].L >> v[i].R >> v[i].C;
        v[i].L--;
    }
    sort(v.begin(), v.end());

    vector<ll> dist(N, 1e17);
    priority_queue<pil, vector<pil>, greater<pil>> que;
    multiset<ll> st;
    int idx = 0;

    dist[0] = 0;
    que.emplace((pil){N, 1e17});
    st.insert(1e17);
    for (int i = 0; i < N; ++i) {
        while (que.top().first <= i) {
            st.erase(st.find(que.top().second));
            que.pop();
        }

        dist[i] = min(dist[i], *st.begin());

        while (idx < M && v[idx].L <= i) {
            st.insert(dist[i] + v[idx].C);
            que.emplace((pil){v[idx].R, dist[i] + v[idx].C});
            idx++;
        }
    }

    cout << (dist[N - 1] < 1e17 ? dist[N - 1] : -1) << endl;

    return 0;
}


Measured memory_bytes: 8076
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
#define R(i,n) for(int i = 1; i<=n; i++)
typedef long long ll;
using namespace std;

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(c>a+b)cout << a+2*b+1<<endl;
  else cout << b+c<<endl;
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int len = S.size();
    if (len == 1)
        cout << 0 << endl;
    else
    {
        if (len%2 == 0)
        {
            int odd = 0, even = 0;
            for (int i = 0; i < len; ++i)
            {
                if (S[i] == '1')
                {
                    if (i%2 == 0)
                        even++;
                    else
                        odd++;
                }
            }

            if (even >= odd)
                cout << len/2-even+odd << endl;
            else
                cout << len/2-odd+even << endl;
        }
        else
        {
            int n1 = 0, n2 = 0, n3 = 0, n4 = 0;
            for (int i = 0; i < len; ++i)
            {
                if (i%2 == 0)
                {
                    if (S[i] == '0')
                        n1++;
                    else
                        n2++;
                }
                else
                {
                    if (S[i] == '1')
                        n3++;
                    else
                        n4++;
                }
            }
            int ct1 = len/2+1-n1 + len/2-n3;
            int ct2 = len/2+1-n2 + len/2-n4;
            if (ct1 < ct2)
                cout << ct1 << endl;
            else
                cout << ct2 << endl;
        }
    }

    return 0;
}

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

int main(){

    int x,n;
    cin >> x >> n;
    set<int> p;
    rep(i,n){
        int t;
        cin >> t;
        p.insert(t);
    }
    int ans=0;
    int mi=10000;
    for(int i=0;i<=101;i++){
        if(p.find(i)!=p.end()){
            continue;
        }else{
            if(mi>abs(x-i)){
                mi=abs(x-i);
                ans=i;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 200004;
const int MOD =998244353
 ;
const int INV2 = (MOD+1)/2;
int k,x,y;


     signed main(){
          int n;
          cin>>n;
          vector<pair<int,int>> w,b;int a;char c;
          for(int i=0;i<2*n;i++){
               cin>>c>>a;
               if(c=='W')w.push_back(make_pair(a,i));
               else b.push_back(make_pair(a,i));
          }
          sort(w.begin(),w.end());sort(b.begin(),b.end());
          int wp[w.size()+1][b.size()+1],bp[w.size()+1][b.size()+1],dp[w.size()+1][b.size()+1];
          int bsize=b.size(),wsize=w.size();
        dp[0][0]=0;
          for(int i=1;i<=w.size();i++){
               wp[i][0]=0;
               for(int j=0;j<i-1;j++)if(w[i-1].second<w[j].second)wp[i][0]++;
               for(int j=1;j<=b.size();j++){
                    wp[i][j]=wp[i][j-1];
                    if(w[i-1].second<b[j-1].second)wp[i][j]++;
               }
          }
          for(int i=1;i<=b.size();i++){
               bp[0][i]=0;
               for(int j=0;j<i-1;j++)if(b[i-1].second<b[j].second)bp[0][i]++;
               for(int j=1;j<=w.size();j++){
                    bp[j][i]=bp[j-1][i];
                    if(b[i-1].second<w[j-1].second)bp[j][i]++;
               }
          }
          for(int i=1;i<=max(w.size(),b.size());i++){
               if(i<=w.size()){
                    dp[i][0]=dp[i-1][0]+wp[i][0];
                    for(int j=1;j<min(bsize+1,i);j++){
                         dp[i][j]=min(dp[i][j-1]+bp[i][j],dp[i-1][j]+wp[i][j]);
                    }
               }
               if(i<=b.size()){
                    dp[0][i]=dp[0][i-1]+bp[0][i];
                    for(int j=1;j<min(i,wsize+1);j++){
                         dp[j][i]=min(dp[j-1][i]+wp[j][i],dp[j][i-1]+bp[j][i]);
                    }
               }
               if(i<=min(w.size(),b.size())){
                    dp[i][i]=min(dp[i][i-1]+bp[i][i],dp[i-1][i]+wp[i][i]);
               }
          }
          cout<<dp[w.size()][b.size()]<<endl;
        





}


        


Measured memory_bytes: 94208
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数

int main() {
	
	ll N;
	vector<ll> A;

	cin>>N;
	for(ll i=0;i<N;i++){
		ll a;
		cin>>a;
		A.push_back(a-(i+1));
	}
	sort(A.begin(),A.end());
	if(N%2==0){
		ll x=A[N/2-1],y=A[N/2],sumx=0,sumy=0;
		for(ll i=0;i<N;i++){
			sumx+=abs(A[i]-x);
			sumy+=abs(A[i]-y);
		}
		cout<<MIN(sumx,sumy)<<endl;
	}else{
		ll x=A[(N-1)/2],sum=0;
		for(ll i=0;i<N;i++){
			sum+=abs(A[i]-x);
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int n,a=0,b=0,ab=0,ans=0;
  vector<string> s(n);
  cin>>n;
  for(int i=0;i<n;i++){
    string t;
    cin>>t;
    for(int j=0;j<t.length()-1;j++){
      if(t[j]=='A'&&t[j+1]=='B') ans++;
    }
    if(t[0]=='B') b++;
    if(t[t.length()-1]=='A') a++;
    if(t[0]=='B'&&t[t.length()-1]=='A') ab++;
    s.push_back(t);
  }
  if(a==0||b==0) ans+=0;
  else if(a==b&&a==ab) ans+=(a-1);
  else ans+=min(a,b);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void)
{
    long long r, d, x;
    cin >> r >> d >> x;

    for (long long i = 0; i < 10; i++)
    {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

money = 1000


for i in range(N-1):
    if A[i] < A[i+1]:
        kabu = money // A[i]
        money -= kabu * A[i]
        money += kabu * A[i+1]
        # print(money, kabu)

print(money)

Measured memory_bytes: 61904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
#define vec vector
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int n;
	cin >> n;
	vector<ll> dp(1 << n, 0); 
	bool g[n][n];
	int x;
	cu(i,0,n){
		cu(j,0,n){
			cin >> x;
			g[i][j] = x == 1;
		}
	}
	dp[0] = 1;
	cu(j,0,1 << n){
		int cnt = 0;
		cu(k,0,n){
			cnt += ((j >> k) & 1);
		}
		cu(k,0,n){
			if(((j >> k) & 1) && g[cnt-1][k]){
				dp[j] += dp[j & ~(1 << k)];	
			}
		}
		dp[j] %= MOD;
	}
	cout << dp[(1 << n) - 1] << '\n';
}


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

using namespace std;

int n;
vector<long long> a;

long long dfs(int now, long long sum) {
	if (now == n) {
		return 0;
	}
	if (now == 0) {
		return min(dfs(now + 1, min(-1LL, a[now])) + abs(min(-1LL, a[now]) - a[now]),
			dfs(now + 1, max(1LL, a[now])) + abs(max(1LL, a[now]) - a[now]));
	}
	if (sum < 0) {
		if (sum + a[now] > 0) {
			return dfs(now + 1, sum + a[now]);
		}
		return dfs(now + 1, 1) + abs(1 - sum - a[now]);
	}
	if (sum + a[now] < 0) {
		return dfs(now + 1, sum + a[now]);
	}
	return dfs(now + 1, -1) + abs(-1 - sum - a[now]);
}

void hawawa()
{
	cin >> n;
	a.resize(n);
	for (auto&& i : a) {
		cin >> i;
	}
	cout << dfs(0, 0) << "\n";
}

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


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll int64_t
#define inf LLONG_MAX

void solve()
{
    ll n,i,ans;
    cin>>n;
    ll arr[n+1];
    ans=0;
    for(i=1;i<=n;i++)    
    {
        cin>>arr[i];
        if(i%2 and arr[i]%2)
            ans++;
    }

    cout<<ans<<endl;
    
}


signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //ll tt;    cin>>tt;    while(tt--)
    {
        solve();
     }
    cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
        
        
return 0;
}

Measured memory_bytes: 3736
numbers_of_line, count_of_numbers, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ar = []
for i in 1..numbers_of_line do
  ar << gets.split.map(&:to_i)
end

count = 0
ar.each_with_index do |a, i|
  r = 0
  a.each_with_index do |a, i|
    r += a * b[i]
  end
  count += 1 if r + c > 0
end
p count

Measured memory_bytes: 1788
while True: #無限に繰り返す
 n = int(input()) #n に審判の数を読み込む
 if n == 0:
          break #n が 0 のときにループから抜ける
 else:
      max_s=0
      min_s=2000
      sum_s=0
      for i in range(n): 
            s=int(input())
            sum_s=sum_s+s
            if s<min_s:
                min_s=s
            if s>max_s:
                max_s=s
      print((sum_s-max_s-min_s)//(n-2))



Measured memory_bytes: 5592
x, n =map(int, input().split())
p = []
if n != 0:
    p = list(map(int, input().split()))

result = x
if n != 0:
    for i in range(0, 1000):
        if not (x - i) in p:
            print(x - i)
            break
        if not (x + i) in p:
            print(x + i)
            break
else:
    print(x)
    

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, M, L, R;
    int TempMin = 0, TempMax = 1000000;
    cin >> N >> M;
    for(int i = 1; i <= M; ++i){
        cin >> L >> R;
        TempMin = max(TempMin, L);
        TempMax = min(TempMax, R);
    }
    cout << max(0, TempMax - TempMin + 1) << endl;
    return 0;
}

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

using namespace std;

#define lli long long 
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
          return left.first < right.first;
}
bool cmps(const pair<double, double> left, const pair<double, double> right) {
          return left.second < right.second;
}


int main(){
	int n, r;
  cin >> n >> r;
  if ( n < 10 )cout << r + 100*(10-n);
    else cout << r;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){
    string S;
    ll K;
    cin >> S >> K;

    ll ans = 0;

    if (S.back()!=S.front()) {
        rep(i,1,S.size()) {
            if (S[i-1]==S[i]) {
                ans++;
                i++;
            }
        }
        ans *=K;
        cout << ans << endl;
    }

    else {
        string tmp = S;
        tmp.erase(unique(tmp.begin(), tmp.end()),tmp.end());

        if (tmp.size()==1) {
            ans = S.size()*K/2;
            cout << ans << endl;
        }

        else {
            rep(i,1,S.size()) {
                if (S[i-1]==S[i]) {
                    ans++;
                    i++;
                }
            }
            S+=S;

            int ans2=0;
            rep(i,1,S.size()) {
                if (S[i-1]==S[i]) {
                    ans2++;
                    i++;
                }
            }
            ans = ans + (K-1)*(ans2-ans);
            cout << ans << endl;
        }
    }

    
}





Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N, x; cin >> N >> x;
    stack<int> st;
    vector<int> ans(2*N+1,0);

    if(N<3){
        if(N != x){
            cout << "No" << endl;
            return 0;
        }
        for(ll i=1; i<=2*N-1; i++){
            ans[i]=i;
        }
    }else{
        if(1<x && x<2*N-1){
            for(int i=0; i<=2; i++){
                if(x+i<=2*N-1)
                    ans[N+i] = x+i;
                if(x-i>0)
                    ans[N-i] = x-i;
            }
            swap(ans[N-1], ans[N+1]);
            for(ll i=1; i<=2*N-1; i++){
                if(x-2 <= i && i <= x+2) continue;
                st.push(i);
            }
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=1; i<=2*N-1; i++){
        if(ans[i]!=0) {
            cout << ans[i] << endl;
        } else{
            cout << st.top() << endl;
            st.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 2928
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000
#define MAXN 100001
#define MOD 1000000007

int N, K;
int D[10];

bool check(int k){
    for(int i = 0;i < K;i++){
        if(k == D[i]) return true;
    }
    return false;
}

bool check_n(int n){
    while(n > 0){
        if(check(n % 10)) return false;
        n /= 10;
    }
    return true;
}
int main(){
    int ans = 0;
    cin >> N >> K;
    for(int i = 0;i < K;i++){
        cin >> D[i];
    }

    for(int i = N;i <= 10 * N;i++){
        ans = i;
        if(check_n(i)) break;
    }

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

}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxk = 1e4+9;
const int maxd = 101;
int dp[maxk][maxd], digit[maxk];
string k; int d;

int dfs(const int i, const int j, const bool limit)
{
    if (i < 0)
        return j == 0;
    if (!limit && dp[i][j] != -1)
        return dp[i][j];
    int ans = 0;
    int last = limit ? digit[i] : 9;
    FOR(x,0,last+1) {
        ans += dfs(i-1, (j+x)%d, limit && (x==last));
        ans %= mod;
    }
    if (!limit)
        dp[i][j] = ans;
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> k >> d) {
        memset(dp,-1,sizeof(dp));
        int n = 0;
        FOR_ALLR(c,k)
            digit[n++] = *c-'0';
        const int ans = dfs(n-1,0,true);        
        cout << (ans-1+mod)%mod << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
struct bug{ll in,out;};
int N,size;
int seg1[1<<20],seg2[1<<20];
bug foo[300050];
bool comp(const bug& a,const bug& b)
{
	return a.in > b.in;
}
struct segtree
{
	segtree(int n)//constructor making segtree
	{
		size=1;
		memset(seg1,0,sizeof(seg1));
		memset(seg2,0,sizeof(seg2));
		while(size<n)size*=2;
	}
	void update(int k,int x)
	{
		k+=size;
		seg1[k]=x;
		seg2[k]=k-size;
		while(k>0)
		{
			k=(k-1)/2;
			if(seg1[k*2+1]>seg1[k*2+2])
			{
				seg1[k]=seg1[k*2+1];
				seg2[k]=seg2[k*2+1];
			}
			else
			{
				seg1[k]=seg1[k*2+2];
				seg2[k]=seg2[k*2+2];
			}
		}
		return;
	}
	int max_id()
	{
		return seg2[0];
	}
	int max_num()
	{
		return seg1[0];
	}
};
bool C(int K)
{
	segtree seg(K);
	ll sum=0ll;
	for(int i=0;i<K-1;i++)
	{
		sum+=(ll)foo[i].out;
		seg.update(i,foo[i].out);
	}
	for(int i=K-1;i<N;i++)
	{
		if(i==K-1)
		{
			sum+=(ll)foo[i].out;
			seg.update(i,foo[i].out);
		}
		else
		{
			if(seg.max_num()>foo[i].out)
			{
				sum-=(ll)(seg.max_num()-foo[i].out);
				seg.update(seg.max_id(),foo[i].out);
			}
		}
		if(sum<=(ll)K*foo[i].in)return true;
	}
	return false;
}
int main()
{
	cin >> N;
	for(int i=0;i<N;i++)cin >> foo[i].out >> foo[i].in;
	sort(foo,foo+N,comp);
	int l=0,r=N;
	while(r>l)
	{
		if(r-l==1)
		{
			if(C(r))l=r;
			break;
		}
		int mid=(l+r)/2;
		if(C(mid))l=mid;
		else r=mid;
	}
	cout << l << endl;
	return 0;
}

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

using ll = long long;

struct block {
    int w, s, v;
    bool operator<(block const& other) const {
        return w + s < other.w + other.s;
    }
};

int main() {
    int n; cin >> n;
    vector<block> bs(n);
    for(int i = 0; i < n; ++i) {
        cin >> bs[i].w >> bs[i].s >> bs[i].v;
    }
    sort(begin(bs), end(bs));

    const int max_s = 1 << 15;
    vector<ll> dp(max_s);
    for(int i = 0; i < n; ++i) {
        for(int j = max_s - 1 - bs[i].w; j >= 0; --j) {
            if(bs[i].s < j) continue;
            dp[j + bs[i].w] = max(dp[j + bs[i].w], dp[j] + bs[i].v);
        }
    }

    cout << *max_element(begin(dp), end(dp)) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
    
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<n; i++){
        ans += ((min(n-1, i*i)/i)*2);
        if(i*i < n){
            ans -= 1;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3640
n,m = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
isGood = Array.new(n,1)
m.times do
  a,b = gets.chomp.split(" ").map(&:to_i)
  if h[a-1] > h[b-1]
    isGood[b-1] = 0
  elsif h[a-1] == h[b-1]
    isGood[a-1] = 0
    isGood[b-1] = 0
  else
    isGood[a-1] = 0
  end
end
puts isGood.count(1)

Measured memory_bytes: 23376
#include "bits/stdc++.h"
/* Properties of modulo:
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
    /*ROLLING HASH
    Rabin-Karp algorithm for pattern matching in a string in O(n) time
    Calculating the number of different substrings of a string in O(n2logn)
    Calculating the number of palindromic substrings in a string.
    */
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define pb push_back
#define gcd __gcd
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
//template<typename T>
//#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
// o_set(ll) name ; -- defining ordered set
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set - returns iterator
bool compare(ll a, ll b){
    return a > b;
}
ll power(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
void solve(){
    string s;
    cin >> s;
    if(s =="ABC") cout << "ARC";
    else cout <<"ABC";
    nl;
}
int main(){
    IOS;
    ll T=1;
    //cin>>T;
    ll t=0;
    while(t++<T){
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3844