akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int x;
  cin>>x;
  int sum = 0;
  int i = 1;
  while(sum < x) {
    sum += i;
    i++;
  }
  cout << i - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[200001];
	int k,x,y,B,i; 
	scanf("%s",s);
	y=strlen(s);
	i=0;
	while(i<y) {

		if  (s[i]=='A') {
			x=i;
			break;
		}
		i=i+1;
	}
	for(i=0;i<y;i++) {
		if(s[i]=='Z')  {
			k=i;
		}
		
	}
	
	B=k-x+1;
	printf("%d\n",B);
	return 0;
}	

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(void) {
    char input[100];
    bool f = 0;
    scanf("%s", input);
    for (int i = 0; i < 100; i++) {
        if (input[i] == 'C') {
            f = true;
        }
        if (f && input[i] == 'F') {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

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

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

    long long int ans = 0;
    for(int i=0; i<n; i++){
        long long int front = 0;
        long long int back = 0;
        for(int j=0; j<i; j++){
            if(a[j] > a[i]) front += 1;
        }
        for(int j=i; j<n; j++){
            if(a[j] > a[i]) back += 1;
        }
        ans += ((k * (k-1) / 2) % MOD) * (front + back) + front * k;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#define INF 100000000
using namespace std;

int main(){
  while(1){
  int n;
  cin >> n;
  if(n == 0) break;
  int t[17][17];
  for(int i=0;i<n;i++)
    for(int j=0;j<n+1;j++) cin >> t[i][j];

  int dp[1<<16]={};
  for(int i=1;i<(1<<n);i++) dp[i] = INF;

  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++)
      if((i&(1<<j)) == 0) {
	int wep = t[j][0];
	for(int k=0;k<n;k++)
	  if((i & (1<<k)) != 0) wep = min(wep,t[j][k+1]);
	dp[i+(1<<j)] = min(dp[i+(1<<j)],dp[i]+wep);
      }
    }
  cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}

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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int A,B,T;cin >> A >> B >> T;
    int ans = (T/A)*B;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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;}

int main(){
	/*?????°????????????????????????????????±??? ????????§??????????????????????????????(EOF)?????§??\????????¨??£????????????*/
	int data[2000];//???????????????????????§0-'a'?????§???????????¨
	REP(i,2000) data[i]=0;
	string str;
	while(cin >> str){/*????????§EOF?????¨???????????????????????????????????§??¬?????? ?????????????????§??????k*/
		REP(i,str.size()){
			int c = str[i];
			if('a'<=str[i]&&str[i]<='z') data[c]++;
			else if('A'<=str[i]&&str[i]<='Z') data[c+('a'-'A')]++;
		}
	}
	FOR(i,(int)'a',(int)'z'+1){
		cout << (char)i  << " : " << data[i] << endl;
	}
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	char c;
	set<char> C;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c;
		C.insert(c);
	}
	if(C.size()==4)
	 cout<<"Four"<<endl;
	else cout<<"Three"<<endl;
	return 0;
 } 

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

int main() {

	string a;

	cin >> a;

	if (a[0]!=a[1]&&a[1]!=a[2]&&a[2]!=a[0]) {
			puts("Yes");
		}

	else {
		puts("No");
	}

}

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

void solve(){  
	long long x;
	cin>>x;
	long long c=0;
	long long sum=100;
	while(sum<x){
		sum+=(sum*0.01);
	    c++;
	}
	cout<<c;
}
int main(){
	ios_base::sync_with_stdio(0); 
    cin.tie(0);
    cout.tie(0);
    solve();
  return 0;
}


Measured memory_bytes: 3652
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n,a,b;
    scan(n, a, b);
    auto ans = min(a*n, b);
    writeln(ans);
}





















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1ll<<(x))
#define inf 10000000000000000
#define MOD 1000000007	
#define N 200005
#define M 100005
#define LOG 20
#define KOK 5880
#define EPS 0.00000001
using namespace std;

map<int,int> prv;
int dp[N],a[N];

int main(int argc,char* argv[]) {

	int n;

	scanf("%d",&n);

	dp[1]=1;

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

		scanf("%d",a+i);

		if(i>1) {

		if(a[i]==a[i-1]) {

			dp[i]=dp[i-1];

		}
		else {

			dp[i]=(dp[i-1]+dp[prv[a[i]]])%MOD;

		}}

		prv[a[i]]=i;
	}

	printf("%d",dp[n]);

}

Measured memory_bytes: 11136
N = int(input())
A = list(map(int,input().split()))
B = [[A[i],i+1] for i in range(N)]
B.sort()
ans = ""
for i in range(N):
    ans = ans+str(B[i][1])
    if i != N-1:
        ans = ans + " "
print(ans)

Measured memory_bytes: 22244
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem169d(n))
}

fun problem169d(n: Long): Long {
    /**
     * 素因数分解
     */
    fun computePrimeFactorList(n: Long): List<Pair<Long, Long>> {
        val p = mutableListOf<Pair<Long, Long>>()
        var primeFactor = n
        // for (i in 2..(Math.sqrt(n.toDouble() / 2) + 1).toLong()) {
        for (i in 2..(Math.sqrt(n.toDouble()) + 1).toLong()) {
            var count = 0L
            while (primeFactor % i == 0L) {
                primeFactor /= i
                count++
                if (primeFactor == 1L) break
            }
            p.add(i to count)
        }
        if (primeFactor != 1L) p.add(primeFactor to 1L)
        return p
    }

    val pf = computePrimeFactorList(n)
    var count = 0L
    for (i in 0 until pf.size) {
        var (a, b) = pf[i]
        var j = 1
        while (b > 0) {
            if (b < j) break
            b -= j
            count++
            j++
        }
    }
    return count
}


Measured memory_bytes: 96620
n = int(input())
h = list(map(int, input().split()))
 
a = [0 for _ in range(n)]
a[1] = abs(h[1] - h[0])
 
for i in range(2,n):
    a[i] = min(a[i-1]+abs(h[i]-h[i-1]), a[i-2]+abs(h[i]-h[i-2]))
    
print(a[-1])

Measured memory_bytes: 13928
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a, b, c, d, e, X, Y ,r;
  long long a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
  int sosuu[46] ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};
  int min =100000001;
  int len=0;
  int l=0;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  for(i=0;;i++){
    c=c-b;
    if(c<=0){
      printf("Yes\n");
      return 0;
    }
    a=a-d;
    if(a<=0){
      printf("No\n");
      return 0;
    }
  }
    
return 0;
}


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

const int N = (int) 1e5;
map<int, int> graph[N];
int lab[N];

int get(int u) {
	return lab[u] == u ? u : lab[u] = get(lab[u]);
}

void setRoot(int v) {
	if (lab[v] == v) return;
	int x = get(v);
	lab[x] = v;
	lab[v] = v;
}

void merge(int u, int v) {
	u = get(u);
	v = get(v);
	if (u != v) lab[u] = v;
}

int main() {
	ios::sync_with_stdio(false);
	int n; cin >> n;
	for (int i = 0; i < n; ++i) lab[i] = i;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v; --u; --v;
		graph[u][v] |= 1;
		graph[v][u] |= 1;
	}
	queue<pair<int, int> > q;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v; --u; --v;
// 		if (u > v) swap(u, v);
		graph[u][v] |= 2;
		graph[v][u] |= 2;
		if (graph[u][v] == 3) q.emplace(u, v);
	}
	int cnt = 0;
	while (!q.empty()) {
		int u = get(q.front().first);
		int v = get(q.front().second);
		q.pop();
// 		cout << u << " " << v << endl;
		if (u == v) continue;
		++cnt;
		if (graph[u].size() > graph[v].size()) swap(u, v);
		graph[u].erase(v);
		graph[v].erase(u);
		for (auto foo : graph[u]) {
			int w = foo.first;
			int val = foo.second;
			graph[w].erase(u);
			int tmp = graph[w][v] = graph[v][w] |= val;
			if (tmp == 3) {
				q.emplace(v, w);
			}
		}
		graph[u].clear();
// 		setRoot(v);
		merge(u, v);
	}
// 	for (int i = 0; i < n; ++i) cout << graph[i].size() << endl;
	cout << (cnt == n - 1 ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 26112
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll t, a;
	cin >> t >> a;
	vector<ll> h(n);
	REP(i,n) cin >> h[i];
	ld diff = INF * INF;
	ll ans = -1;
	REP(i,n) {
		if(max(a - (t - h[i] * 0.006), (t - h[i] * 0.006) - a) < diff) {
			diff = max(a - (t - h[i] * 0.006), (t - h[i] * 0.006) - a);
			ans = i;
		}
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int A, B;

int main(void){
    
    scanf("%d %d", &A, &B);
    printf("%d\n", (A + B < 24) ? A + B : A + B - 24);
    
    return 0;
}

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

import sys
sys.setrecursionlimit(10 ** 6)

class Tree:
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        self.depth = [0 for _ in range(n)]
        self.children = [[] for _ in range(n)]

    def add(self, x, children):
        self.children[x] = children
        for child in children:
            self.parent[child] = x

    def update(self):
        root = -1
        for node, p in enumerate(self.parent):
            if p == -1:
                root = node
                break
        stack = [root]
        d = 0
        while stack:
            temp = []
            for node in stack:
                self.depth[node] = d
                temp += self.getChildren(node)
            stack = temp
            d += 1
    
    def getParent(self, x):
        return self.parent[x]
    
    def getChildren(self, x):
        return self.children[x]

    def getDepth(self, x):
        return self.depth[x]

    def isRoot(self, x):
        return self.getParent(x) == -1

    def isLeaf(self, x):
        return self.getChildren(x) == []

    def getType(self, x):
        if self.isRoot(x):
            return 'root'
        elif self.isLeaf(x):
            return 'leaf'
        return 'internal node'
    
N = int(input())
t = Tree(N)

for _ in range(N):
    q = list(map(int, input().split()))
    i = q[0]
    k = q[1]
    childs = q[2:]
    t.add(i, childs)

t.update()

for i in range(N):
    print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(i, t.getParent(i), t.getDepth(i), t.getType(i), t.getChildren(i)))



Measured memory_bytes: 24920
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;

const int nax = 2e5 + 5;
char s[nax];

int n;

bool ok(int a, int b) {
	assert(a <= b);
	// if(a > b) {
		// swap(a, b);
	// }
	while(a < b) {
		if(s[a+1] == '.') {
			++a;
		}
		else if(a + 2 < n && s[a+2] == '.') {
			a += 2;
		}
		else {
			return false;
		}
	}
	assert(a == b);
	return true;
}

void NO() {
	puts("No");
	exit(0);
}
void YES() {
	puts("Yes");
	exit(0);
}

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	--a;
	--b;
	--c;
	--d;
	scanf("%s", s);
	if(!ok(a, c) || !ok(b, d)) {
		NO();
	}
	if(c > d) {
		int i = b - 1;
		while(i + 2 < n && !(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.')) {
			++i;
		}
		if(i + 1 <= d && ok(a, i)) {
			YES();
		}
		else {
			NO();
		}
		// if(i + 2 < n && ok(a, i)) {
			// YES();
		// }
		// i = a;
		// while(i >= 2 && !(s[i] == '.' && s[i-1] == '.' && s[i-2] == '.')) {
			// --i;
		// }
		// if(i >= 2 && ok(a, i)) {
			// YES();
		// }
		// NO();
	}
	
	YES();
}


Measured memory_bytes: 384
#include <stdio.h>
#define MIN 1000000000
#define MAX 0

int main(void){
  int min=MIN,max=MAX,a,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if( a < min ) min=a;
    if( max < a ) max=a;
  }
  
  printf("%d\n",max-min);
  
  return 0;
}

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

using P = pair<int, int>;

constexpr int INF = 1e9;

int bfs(vector<string> const& v, int sy, int sx, int gy, int gx) {
    vector<vector<int>> d(v.size(), vector<int>(v[0].size(), INF));
    queue<P> que;
    que.push(P{sy, sx});
    d[sy][sx] = 0;
    while(!que.empty()) {
        P p = que.front();
        que.pop();
        int dx[4] = {0, 1, 0, -1},
            dy[4] = {1, 0, -1, 0};
        for(int i=0; i<4; ++i) {
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(ny < 0 || v.size() <= ny || nx < 0 || v[0].size() <= nx || d[ny][nx] != INF) {
                continue;
            }
            if(v[ny][nx] != 'X') {
                d[ny][nx] = d[p.first][p.second] + 1;
                que.push(P{ny, nx});
            }
        }
    }
    return d[gy][gx];
}

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<string> v(H);
    for(int i=0; i<H; ++i) {
        cin >> v[i];
    }
    vector<int> gx(N+1), gy(N+1);
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            if(v[i][j] == 'S') {
                gy[0] = i;
                gx[0] = j;
            }
            if(isdigit(v[i][j])) {
                gy[v[i][j]-'0'] = i;
                gx[v[i][j]-'0'] = j;
            }
        }
    }
    int res = 0;
    for(int i=0; i<N; ++i) {
        res += bfs(v, gy[i], gx[i], gy[i+1], gx[i+1]);
    }
    cout << res << endl;
}


Measured memory_bytes: 7756
import Control.Applicative
import System.IO

main :: IO ()
main = do
  s <- getContents
  let lns = map words $ lines s
  if length lns <= 200
     then let arr  = map (read :: String -> Int) <$> lns
              sums = map (foldl (+) 0) arr
           in mapM_ print $ map (length . show) sums
    else return ()



Measured memory_bytes: 4028
#include<stdio.h>
int main()
{
    int n,k,s;
    scanf("%d%d%d",&n,&k,&s);
    if(n==k)
    {
        for(int i=1;i<=n;i++)
        {   if(i!=n)
            printf("%d ",s);
            else
            printf("%d",s);
        }
    }
    else
    {
        for(int i=1;i<=k;i++)
        {
            printf("%d ",s);
        }
        for(int i=1;i<=n-k;i++)
        {
            if(s==1000000000)
            {
            if(i!=n-k)
            printf("%d ",s-1);
            else
            printf("%d",s-1);
            }
            else
            {
            if(i!=n-k)
            printf("%d ",s+1);
            else
            printf("%d",s+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long
typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
    mat C(A.size(), vec(B[0].size()));
    for(int i = 0; i < A.size(); i++) {
        for(int j = 0; j < B[0].size(); j++) {
            for(int k = 0; k < B.size(); k++) C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
        }
    }
    return C;
}

mat pow(mat A, ll n) {
    mat B(A.size(), vec(A.size()));
    for(int i = 0; i < A.size(); i++) B[i][i] = 1;
    if(n == 0) return B;
    mat C(A.size(), vec(A.size()));
    C = pow(mul(A, A), n / 2);
    if(n & 1) C = mul(C, A);
    return C;
}

void solve() {
	int n; ll k; cin >> n >> k;
    mat A(n, vec(n));
    rep(i, n) {
        rep(j, n) {
            cin >> A[i][j];
        }
    }
    A = pow(A, k);
    ll ans = 0;
    rep(i, n) {
        rep(j, n) {
            (ans += A[i][j]) %= mod;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 2000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
	ll x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }


/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1; y = 0; return a;
	}
	ans = exgcd(b, a%b, x, y);
	ll t = x; x = y; y = t - a / b * y;
	return ans;
}
*/

int n;
ll a[maxn];
ll lftmax[maxn], minrgt[maxn];
int main() {
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i <3* n; i++)rdint(a[i]);
	priority_queue<int, vector<int>, greater<int> >q1;
	priority_queue<int>q2;
	for (int i = 0; i < n; i++) {
		lftmax[0] += a[i]; q1.push(a[i]);
		minrgt[n + 1] += a[3 * n - i - 1]; q2.push(a[3 * n - i - 1]);
	}
	for (int i = 1; i <= n; i++) {
		q1.push(a[n + i - 1]);
		lftmax[i] = lftmax[i - 1] + a[n + i - 1] - q1.top();
		q1.pop();
		q2.push(a[n * 2 - i]);
		minrgt[n - i + 1] = minrgt[n + 1 - i + 1] + a[n * 2 - i] - q2.top();
		q2.pop();
	}
	ll res = -inf;
	for (int i = 0; i <= n; i++) {
		if (i == 0)res = lftmax[i] - minrgt[i + 1];
		else res = max(res, lftmax[i] - minrgt[i + 1]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10228
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



// mod演算ライブラリ (factset以降に関しては, modは素数限定)
ll mod = 1000000007;

ll add_mod(ll a, ll b) {  // a + b
	return (a + b) % mod;
}

ll sub_mod(ll a, ll b) {  // a - b
	return (a + mod - b) % mod;
}

ll mul_mod(ll a, ll b) {  // a * b
	return ((a % mod) * (b % mod)) % mod;
}

ll pow_mod(ll x, ll y) { // x^y 単品利用可
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) {
		ll tmp = pow_mod(x, y / 2) % mod;
		return tmp * tmp % mod;
	}
	else {
		ll tmp = pow_mod(x, y / 2) % mod;
		return ((tmp * tmp) % mod) * x % mod;
	}
}

ll dvs_mod(ll a, ll b) {
	return mul_mod(a, pow_mod(b, mod - 2));
}

const ll SIZE_mod = 300005;
ll invfact[SIZE_mod];
ll fact[SIZE_mod];

void factset(ll a) {  // a までの 階乗 % mod 表を作成
	fact[0] = 1;
	for (ll i = 1; i <= a; ++i) {
		fact[i] = mul_mod(fact[i - 1], i);
	}
}

void cmbset(ll a) {  // 1~a までの階乗と階乗数の逆元のmod(mod)を用意 O(a)
	factset(a);
	invfact[a] = pow_mod(fact[a], mod - 2);
	invfact[0] = 1;
	for (ll i = a - 1; i >= 1; --i) {
		invfact[i] = mul_mod(invfact[i + 1], i + 1);
	}
}

ll cmb_mod(ll n, ll r) {  // nCr % mod  (cmbset後に使用)
	if (n < r || r < 0 || n < 0) return 0;
	return mul_mod(fact[n], mul_mod(invfact[r], invfact[n - r]));
}

ll prm_mod(ll n, ll r) {  // nPr % mod
	return mul_mod(cmb_mod(n, r), fact[r]);
}

ll homo_mod(ll n, ll r) {  // nHr % mod
	return cmb_mod(n + r - 1, r);
}




int main() {
	cmbset(200000);
	
	ll N, M;
	cin >> N >> M;

	map<ll, ll> div_num;
	ll m = M;
	while (1 < m) {
		bool div = false;
		fori(i, 2, sqrt(M) + 1) {
			if (m % i == 0) {
				++div_num[i];
				m /= i;
				div = true;
				break;
			}
		}
		if (!div) {
			++div_num[m];
			break;
		}
	}

	ll ans = 1;
	for (auto p : div_num) {
		ans = mul_mod(ans, homo_mod(N, p.second));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main() {
    int a,b,c;
    b = 0;
    c = 0;
    cin >> a;
    if (a < 15){
       cout << a * 800 << endl;
    } else if (a >= 15){
        for (int i = 15; i <= a; ++i) {
            if (i % 15 == 0) {
                b++;
            }
        }
        c = b * 200;
        cout << (a*800) - (c) << endl;
    }
    return 0;
}

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

while mon[0] > 0:
        mon[2] = mon[2] - mon[1]
        if (mon[2] <= 0):
                print ("Yes")
                break
        else:
                mon[0] = mon[0] - mon[3]
                if (mon[0] <= 0):
                        print ("No")
                        break

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int h, w, m;
  cin >> h >> w >> m;
  vector<pair<int,int>> bom(m);
  map<int,int> tate;
  map<int,int> yoko;
  map<int, map<int,bool>> mp;

  REP(i,m){
    int t, y;
    cin >> t >> y;
    bom[i] = make_pair(t,y);
    tate[t]++;
    yoko[y]++;
    mp[t][y] = true;
  }

  int tatemax = 0;
  int yokomax = 0;
  for(auto x: tate){
    if(tatemax < x.second){
      tatemax = max(tatemax, x.second);
    }
  }
  for(auto x: yoko){
    if(yokomax < x.second){
      yokomax = max(yokomax, x.second);
    }
  }

  int ans = tatemax + yokomax;


  //その点がにボムがあったら-1
  vector<int> tatekouho;
  vector<int> yokokouho;
  for(auto x: tate){
    if(x.second == tatemax){
      tatekouho.push_back(x.first);
    }
  }
  for(auto x: yoko){
    if(x.second == yokomax){
      yokokouho.push_back(x.first);
    }
  }
  sort(ALL(tatekouho));
  sort(ALL(yokokouho));
  // // for(auto x: tatekouho) cout << x << endl;
  // // cout <<"yoko" <<endl;
  // // for(auto x: yokokouho) cout << x << endl;

  // int bar[h+1][w+1] = {};
  // REP(i,m){
  //   bar[bom[i].first][bom[i].second] = 1;
  // }

  // // REP(i,h+1){
  // //   REP(j,w+1){
  // //     cout << bar[i][j];
  // //   }
  // //   cout << endl;
  // // }

  // //M回捜索
  // bool ok = true;
  // REP(i,tatekouho.size()){
  //   REP(j,yokokouho.size()){
  //     //cout << tatekouho[i] << " " << yokokouho[j] << endl;
  //     if(bar[tatekouho[i]][yokokouho[j]] != 1) {
  //       ok = false;
  //       break;
  //     }
  //   }
  // }
  //M回捜索
  bool ok = true;
  REP(i,tatekouho.size()){
    REP(j,yokokouho.size()){
      //cout << tatekouho[i] << " " << yokokouho[j] << endl;
      if(mp[tatekouho[i]][yokokouho[j]]) continue;
      ok = false;
      break;
    }
  }

  if(!ok) cout << ans << endl;
  else cout << ans-1 << endl;

  return 0;
}

Measured memory_bytes: 92364
s = input()
if s == "SUN":
    print (7)
elif s == "MON":
    print (6)
elif s == "TUE":
    print (5)
elif s == "WED":
    print (4)
elif s == "THU":
    print (3)
elif s == "FRI":
    print (2)
else: #SAT
    print (1)


Measured memory_bytes: 2940
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();
        int a = 0;
        int b = 0;
        int c = 0;
        for(int i = 0; i < S.length(); i++){
            if(S.charAt(i) == 'a')
                a++;
            else if(S.charAt(i) == 'b')
                b++;
            else
                c++;
        }

        if(Math.max(Math.abs(a-b), Math.max(Math.abs(b-c),Math.abs(c-a))) <= 1)
            System.out.println("YES");
        else
            System.out.println("NO");
   }
}

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

int main() {
	string X;
	cin >> X;
	int S = 0, T = 0;
	for (char c : X) {
		if (c == 'S') S++;
		else {
			if (S > 0) S--;
			else T++;
		}
	}
	cout << S + T << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
#define DEBUG
#ifdef DEBUG
#endif
const int maxn = 5e5+10;


int dp[maxn], ans = 0;
char str[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int n, pre = 0;
    scanf("%d", &n);
    scanf("%s", str+1);
    Fill(dp, 0);
    for(int i = 3; i <= n; i++)
    {//Debug(str[i]);
    	dp[i] = dp[i-1];
    	if(str[i]=='0')pre = 0;
    	if(str[i]=='1'&&str[i-1]=='0'&&str[i-2]=='1')
    	{
    		int j = i-2;
    		while(j&&str[j]=='1')
    		{
    			dp[i] = max(dp[i], dp[j-1]+i-j-1);
    			j--;
    		}
    		pre = i;
    	}
    	if(str[i]=='1'&&pre)
    	{
    		dp[i] = max(dp[i], dp[pre-3]+i-pre+1);
    	}
    }
    //cout<<"dp:\n";for(int i = 1; i<=n; i++)cout << dp[i] << " "; cout << endl;
    printf("%d\n", dp[n]);






















    return 0;
}


Measured memory_bytes: 2688
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define N_MAX 100001

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N;
	scanf("%d", &N);

	long long int table[N_MAX], bsum = 0;
	for (int i = 0; i < N; i++){
		int a, b; scanf("%d%d", &a, &b);
		table[i] = -(a + b);
		bsum += b;
	}

	sort(table, table + N);

	long long int ret = -bsum;
	for (int i = 0; i < N; i+=2){
		ret -= table[i];
	}

	printf("%lld", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repS(s,n) for(int (s) = 0; s < 1 << (n); ++(s))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1 << 30);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


int N;

void solve(){
	
	return;
}

void input(){
	
	cin>>N;
	int a,t,m = INF;
	
	rep(i,N){
		cin>>a;
		t = 0;
		while(!(a & 1)){
			++t;
			a >>= 1;
		}
		m = min(t,m);
	}
	
	cout<<m<<endl;
	
	return;
}

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





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
static const long long INF = 1000000;
using p = pair<int,int>;
int main(){
    int64_t x,ans;
    cin >> x;
    int a,b,c;
    a = x/500;
    b = x - 500*a;
    c = b/5;
    ans = 1000*a + c*5;
    cout << ans << endl;
    
}

Measured memory_bytes: 3608
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int h=read(),w=read(),n=read(),ans[150][150],nx=1,ny=1;

int main(){
int i;
for (i=1;i<=n;++i){
  int x=read();
  for (;nx<=h&&x>0;){
    if (nx&1){
      for (int &k=ny;k<=w&&x-->0;++k) ans[nx][k]=i;
	  }
	else{
	  for (int &k=ny;k&&x-->0;--k) ans[nx][k]=i;
	  }
	if (!ny||ny>w){
	  ++nx;
	  if (!ny) ++ny;
	  if (ny>w) --ny;
	  } 
    }
  }
for (i=1;i<=h;++i,pl){
  for (int j=1;j<=w;++j,p32) write(ans[i][j]);
  }
}

Measured memory_bytes: 384
IDENTIFICATION DIVISION.
PROGRAM-ID. 162D.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC  9(4).
01 S          PIC  X(4000).
01 I1         PIC  9(4) COMP.
01 I2         PIC  9(4) COMP.
01 I3         PIC  9(4) COMP.
01 IR         PIC  9(4) COMP.
01 IG         PIC  9(4) COMP.
01 IB         PIC  9(4) COMP.
01 IW         PIC  9(4) COMP.
01 KS         PIC  9(18).
01 S1         PIC  9(4) COMP.
01 M1         PIC S9(4) COMP.
01 M2         PIC S9(4) COMP.
01 M3         PIC S9(4) COMP.
01 MP         PIC  9(4) COMP.
01 AMR        PIC  9(1) COMP.
01 OUT        PIC  Z(17)9.
01 TBL-R.
   03 RN      PIC  9(4) COMP OCCURS 4001.
   03 RN2     PIC  9(1)      OCCURS 4001.
01 TBL-G.
   03 GN      PIC  9(4) COMP OCCURS 4001.
   03 GN2     PIC  9(1)      OCCURS 4001.
01 TBL-B.
   03 BN      PIC  9(4) COMP OCCURS 4001.
   03 BN2     PIC  9(1)     OCCURS 4001.
01 TBL-W.
   03 WN      PIC  9(4) COMP OCCURS 4001.
   03 WN2     PIC  9(1)      OCCURS 4001. 
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT S.
*>
  MOVE ZERO TO TBL-R TBL-G TBL-B.
  PERFORM VARYING I1 FROM 1 BY 1 UNTIL I1 > 4001
    MOVE 0 TO RN(I1) GN(I1) BN(I1)
  END-PERFORM.
*>
  MOVE 0 TO IR IG IB.
  PERFORM VARYING I1 FROM 1 BY 1 UNTIL I1 > N
    EVALUATE S(I1:1)
      WHEN 'R'
        ADD   1 TO IR
        MOVE I1 TO RN(IR)
        MOVE  1 TO RN2(I1)
      WHEN 'G'
        ADD   1 TO IG
        MOVE I1 TO GN(IG)
        MOVE  1 TO GN2(I1)
      WHEN 'B'
        ADD   1 TO IB
        MOVE I1 TO BN(IB)
        MOVE  1 TO BN2(I1)
    END-EVALUATE  
  END-PERFORM.
*>
  EVALUATE TRUE
    WHEN IR >= IG AND IR >= IB
      MOVE TBL-R TO TBL-W
      MOVE IR    TO IW
      MOVE TBL-B TO TBL-R
      MOVE IB    TO IR
      MOVE TBL-W TO TBL-B
      MOVE IW    TO IB
    WHEN IG >= IR AND IG >= IB
      MOVE TBL-G TO TBL-W
      MOVE IG    TO IW
      MOVE TBL-B TO TBL-G
      MOVE IB    TO IG
      MOVE TBL-W TO TBL-B
      MOVE IW    TO IB
  END-EVALUATE.      
*>
  MOVE 0 TO KS.
 if (IR > 0) AND (IG > 0) AND (IB > 0)
  PERFORM VARYING I1 FROM 1 BY 1 UNTIL I1 > IR
    PERFORM VARYING I2 FROM 1 BY 1 UNTIL I2 > IG
      COMPUTE S1 = RN(I1) - GN(I2)
      COMPUTE MP = RN(I1) + GN(I2)
      DIVIDE MP BY 2 GIVING M2 REMAINDER AMR
      IF (AMR = 1)
        MOVE 4001 TO M2
      END-IF
*>
      IF (RN(I1) < GN(I2))
        COMPUTE M1 = RN(I1) - S1
        IF (M1 < 1)
          MOVE 4001 TO M1
        END-IF
        COMPUTE M3 = GN(I2) + S1
        IF (M3 > N)
          MOVE 4001 TO M3
        END-IF
      ELSE
        COMPUTE M1 = GN(I2) - S1
        IF (M1 < 1)
          MOVE 4001 TO M1
        END-IF
        COMPUTE M3 = RN(I1) + S1
        IF (M3 > N)
          MOVE 4001 TO M3
        END-IF
      END-IF
*>
      COMPUTE KS = KS + IB - BN2(M1) - BN2(M2) - BN2(M3)
    END-PERFORM
  END-PERFORM
 END-IF.
*>
  MOVE KS TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<int> a(N);
  vector<int> b(N+1);
  for(int i=0;i<N;++i){
    cin>>a[i];
    ++b[a[i]];
  }
  
  sort(b.begin(),b.end(),greater<int>());
  
  int count=0;
  int ans=0;
  for(int i=0;i<N;++i){
    if(b[i]>0){
      ++count;
    }
    if(count==K){
      for(int j=i+1;j<N;++j){
        ans+=b[j];
      }
      break;
    }
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 1792
'use strict';

const main = input => {
  input = input.split('\n');
  const N = Number(input[0]);
  const A1 = input[1].split(' ');
  const A2 = A1.concat();
  bubbleSort(A1, N);
  console.log(A1.join(' '));
  console.log('Stable');
  selectionSort(A2, N);
  console.log(A2.join(' '));
  console.log(A2.every((v, i) => v === A1[i]) ? 'Stable' : 'Not stable');
};

function bubbleSort(A, N) {
  for (let i = 0; i < N - 1; ++i) {
    for (let j = N - 1; j >= i + 1; --j) {
      if (Number(A[j - 1][1]) > Number(A[j][1])) {
        const tmp = A[j];
        A[j] = A[j - 1];
        A[j - 1] = tmp;
      }
    }
  }
}

function selectionSort(A, N) {
  for (let i = 0; i < N - 1; ++i) {
    let minj = i;
    for (let j = i; j < N; ++j) {
      if (Number(A[j][1]) < Number(A[minj][1])) {
        minj = j;
      }
    }
    if (i !== minj) {
      const tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 15384
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,a[1000],b[1000],i,x;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++) scanf("%d %d",&a[i],&b[i]);
	sort(a,a+m);
	x=0;
	for(i=1;i<m;i++){
		if(a[i]>=n) break;
		x=n-a[i]+x;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2788
#include <stdio.h>

int main(){
   int  i,j,k,n;
   long ans;

   scanf("%d",&n);
   ans=0;
   for (i=1;i<n;i++)
      for (j=1;i*j<n;j++) ans++;
   printf("%ld\n",ans);
   return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int turn = 0;
  while (a > 0 && c > 0) {
    if (turn == 0) {
      c -= b;
      turn = 1;
      continue;
    }
    if (turn == 1) {
      a -= d;
      turn = 0;
      continue;
    }
  }
  if (a <= 0) printf("No\n");
  if (c <= 0) printf("Yes\n");
  return 0;
}

Measured memory_bytes: 3636
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
int main() 
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,l = 0,r = 0;
  cin >> n;
  vector<int> v(n),q(n),p(n);
  for (int i = 0; i < n; ++i)
  {
    v[i] = i+1;
    cin >> p[i];
  }
  for (int i = 0; i < n; ++i)
  {
    cin >> q[i];
  }
  int c = 0;
  do
  {
    c++;
    if (v == q)
      l = c;
    if (v == p)
      r = c;
  }while(next_permutation(v.begin(),v.end()));
  cout << abs(l-r);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
  
struct Stack{
  ll table[1000];
  ll top;
  void init(){
    top=0;
  }
  bool empty(){
    return top==0;
  }
  void push(ll x){
    table[top]=x;
    top++;
  }
  ll pop(){
    if(empty())return 0;
    top--;
    return table[top];
  }
};
  
ll calc(ll x,string op,ll y){
  if(op=="+")return x+y;
  if(op=="-")return x-y;
  if(op=="*")return x*y;
}
  
  
int main(){
  string str;
  ll numA,numB;
  Stack stack;
  stack.init();
  
  while(cin>>str){
    if(str=="+"||str=="-"||str=="*"){
      numA=stack.pop();
      numB=stack.pop();
      stack.push(calc(numB,str,numA));
    }else{
      numA=0;
      for(int i=0;i<(int)str.size();i++){
    numA*=10;
    numA+=str[i]-'0';
      }
      stack.push(numA);
    }
  }
  cout<<stack.pop()<<endl;
  return 0;
}


Measured memory_bytes: 3136
n,k=map(int,input().split())
arr=list(map(int,input().split()))
flag=format(k,'b')[::-1]
l=len(flag)
xor1=0
cnt=0
for i in range(l-2,-1,-1):
  for j in arr:
    if j&(2**i)!=0:
      cnt+=1
  if cnt<=n//2:
    xor1+=2**i
  cnt=0
ans1=0
for i in arr:
  ans1+=i^xor1
xor2=0
cnt=0
check=False
for i in range(l-1,-1,-1):
  if check==False and flag[i]=='0':
    continue
  for j in arr:
    if j&(2**i)!=0:
      cnt+=1
  if cnt<=n//2:
    if check==True or flag[i]=='1':
      xor2+=2**i
  else:
    if flag[i]=='1':
      check=True
  cnt=0
ans2=0
for i in arr:
  ans2+=i^xor2
print(max(ans1,ans2))

Measured memory_bytes: 69336
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

Q, H, S, D = MAP()
N = INT()

ans1 = 4*Q*N
ans2 = 2*H*N
ans3 = S*N
ans4 = D*(N//2) + min(4*Q, 2*H, S)*(N%2)

print(min(ans1, ans2, ans3, ans4))


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

int main() {
  int N; cin >> N;
  vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i];
  int ans = 0;
  while (true) {
    bool f = false;
    for (int i = 0; i < N; i++) {
      if (a[i] % 2 == 1) f = true;
      else a[i] /= 2;
    }
    if (f) break;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256