akhauriyash/Code-Regression huggingface dataset:
/**********************************/
	#include <bits/stdc++.h>
	#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define lli long long int
	#define pb push_back
	#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp>
	#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
	using namespace __gnu_pbds;
	using namespace std;
	const lli MAX=1000000;
	const lli mod=1e9+7;
	/**********************************/
	auto cmp=[](const pair<lli,string>&p1,const pair<lli,string>&p2){return (p1.first>p2.first)||(p1.first==p2.first&&p1.second<p2.second);};
	struct order{
		template<class T>
		bool operator()(T const& a,T const& b){
			if(a.first==b.first)
				return a.second<b.second;
			return a.first>b.first;
		}
	};
	struct HASH{
	  size_t operator()(const pair<lli,lli>&x)const{
	    return hash<lli>()(((long long)x.first)^(((long long)x.second)<<32));
	  }
	};
	/**********************************/

lli maxsubarray(vector<lli> &v,lli n){
	lli max_so_far=v[0],cur_max=v[0],i;
	for(i=1;i<n;i++){
		cur_max = max(v[i],cur_max+v[i]);
		max_so_far=max(cur_max,max_so_far);
	}
	return max_so_far;
}
void multiply(lli F[(lli)2][(lli)2], lli M[(lli)2][(lli)2]); 
  
void power(lli F[(lli)2][(lli)2], lli n); 
  
lli fib(lli n) 
{ 
  lli F[(lli)2][(lli)2] = {{1,1},{1,0}}; 
  if (n == 0) 
    return 0; 
  power(F, n-1); 
  return F[0][0]; 
} 

void power(lli F[(lli)2][(lli)2], lli n) 
{ 
  if( n == 0 || n == 1) 
      return; 
  lli M[(lli)2][(lli)2] = {{1,1},{1,0}}; 
  
  power(F, n/2); 
  multiply(F, F); 
  
  if (n%2 != 0) 
     multiply(F, M); 
} 
  
void multiply(lli F[(lli)2][(lli)2], lli M[(lli)2][(lli)2]) 
{ 
  lli x =  (((F[0][0]%mod)*(M[0][0]%mod))%mod + ((F[0][1]%mod)*(M[1][0]%mod))%mod)%mod;
  lli y =  (((F[0][0]%mod)*(M[0][1]%mod))%mod + ((F[0][1]%mod)*(M[1][1]%mod))%mod)%mod;  
  lli z =  (((F[1][0]%mod)*(M[0][0]%mod))%mod + ((F[1][1]%mod)*(M[1][0]%mod))%mod)%mod; 
  lli w =  (((F[1][0]%mod)*(M[0][1]%mod))%mod + ((F[1][1]%mod)*(M[1][1]%mod))%mod)%mod; 
  
  F[0][0] = x; 
  F[0][1] = y; 
  F[1][0] = z; 
  F[1][1] = w; 
} 
lli dp[100005];
lli solve(lli h[],lli i,lli n,lli k){
	if(i>=n-1)
		return 0;
	if(dp[i]!=-1)
		return dp[i];
	lli ans=INT_MAX;
	for(int j=1;j<=k;j++){
		if(i+j<n)
		ans = min(ans,(abs(h[i+j]-h[i])+solve(h,i+j,n,k)));
		else
			break;
	}
	dp[i]=ans;
	return ans;
}

int main(){
	fast;
	lli n,i,k;
	cin>>n>>k;
	lli h[n];
	for(i=0;i<n;i++){
		cin>>h[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(h,0,n,k);
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		if(n == 0) {
			System.out.println(0);
		} else if(n > 0) {
			String ans = "";
			int tmp = 0;
			while(n != 0) {
				if((n & 1) == 1) {
					ans = "1" + ans;
					if(tmp % 2 != 0) {
						n = n + 2;
					}
				} else {
					ans = "0" + ans;
				}
				n = n >> 1;
				tmp++;
			}
			System.out.println(ans);
		} else {
			n = -n;
			String ans = "";
			int tmp = 0;
			while(n != 0) {
				if((n & 1) == 1) {
					ans = "1" + ans;
					if(tmp % 2 == 0) {
						n = n + 2;
					}
				} else {
					ans = "0" + ans;
				}
				n = n >> 1;
				tmp++;
			}
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 22996
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

#define DATA_MAX_NUM 100

void dump_array(int32_t num, int32_t data[])
{
  int i;
  for (i = 0; i < num; i++) {
    if (0 < i) printf(" ");
    printf("%d", data[i]);
  }
  printf("\n");
  return;
}

void bubble_sort(int32_t num, int32_t data[])
{
  bool flag = true;
  int j = 0;
  int count = 0;
  while (flag) {
    flag = false;
    for (j = num - 1; 0 < j; j--) {
      if (data[j - 1] > data[j]) {
        int v = data[j];
        data[j] = data[j - 1];
        data[j - 1] = v;
        flag = true;
        count++;
      }
    }
  }
  dump_array(num, data);
  printf("%d\n", count);
  return;
}
int main(void)
{
  int32_t i = 0;
  int32_t num = 0;
  int32_t data[DATA_MAX_NUM];

#if defined(TEST)
  int32_t test[] = {5, 3, 2, 4, 1};

  dump_array(sizeof(test) / sizeof(test[0]), test);
  bubble_sort(sizeof(test) / sizeof(test[0]), test);
  dump_array(num, data);
#else
  scanf("%d", &num);

  for (i = 0; i < num; i++) {
    scanf("%d ", &data[i]);
  }

  bubble_sort(num, data);
#endif
  return 0;
}

Measured memory_bytes: 608
#include<stdio.h>
#include<algorithm>
using namespace std;
int cur;
char str[210];
int perm[3]={0,1,2};
char ch[5]="+-*";
int lv[3];
long long expr(int a){
	if(a==3){
		if(str[cur]=='('){
			cur++;
			long long ret=expr(0);
			cur++;
			return ret;
		}else{
			long long ret=0;
			while('0'<=str[cur]&&str[cur]<='9'){
				ret*=10;
				ret+=str[cur]-'0';
				cur++;
			}
			return ret;
		}
	}
	long long ret=expr(a+1);
	while((str[cur]=='+'&&lv[0]==a)||(str[cur]=='-'&&lv[1]==a)||(str[cur]=='*'&&lv[2]==a)){
		char tm=str[cur];
		cur++;
		long long tmp=expr(a+1);
		if(tm=='+')ret+=tmp;
		else if(tm=='-')ret-=tmp;
		else ret*=tmp;
	}
	return ret;
}
int main(){
	scanf("%s",str);
	long long ret=expr(0);
	for(int i=0;i<3;i++)for(int j=0;j<3;j++)for(int k=0;k<3;k++){
		lv[0]=i;lv[1]=j;lv[2]=k;
		cur=0;
		ret=max(ret,expr(0));
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 968
#include <stdio.h>
int main(){
	char t[2];
	int a,b,o,ab,s;
	a=b=o=ab=0;
	while(scanf("%d,%s",&s,t)!=EOF){
		if(t[1]=='B') ab++;
		else if(t[0]=='A') a++;
		else if(t[0]=='B') b++;
		else if(t[0]=='O') o++;
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
	return 0;
}

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

typedef long long ll;

ll N, M;
char S[1000000], T[1000000];

void swap(ll N, ll M) {
    ll tmp = N;
    N = M;
    M = tmp;
}

ll gcd(ll N, ll M) {
    if (N < M) {
        swap(N, M);
    }
    ll r = 1;
    while (r != 0) {
        r = N % M;
        N = M;
        M = r;
    }
    return N;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> S[i];
    for (int i = 0; i < M; i++) cin >> T[i];
    
    ll g = gcd(N, M);
    ll l = N * M / g;
    ll n = N / g;
    ll m = M / g;
    bool flag = true;
    for (int i = 0; i <= g - 1; i++) {
        if (S[i * n] != T[i * m]) {
            flag = false;
            break;
        }
    }
    
    if (flag) cout << l << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
//typedef pair<int, pair<int, int> > p;
 
#define MOD 1000000007

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

    ll N, K;
    cin >> N >> K;

    vector<ll> P(N);
    vector<ll> C(N);

    for(int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
    }

    for(int i = 0; i < N; i++) {
        cin >> C[i];
    }

    vector<ll> l(N);
    vector<ll> c(N);
    vector<vector<ll> > m(N);

    ll ans = -pow(10, 18);

    for(int i = 0; i < N; i++) {
        int p = P[i];
        ll count = 0;
        m[i].push_back(0);
        ll ma = -pow(10, 18);
        while(p != i) {
            count += C[p];
            ma = max(ma, count);
            m[i].push_back(ma);
            p = P[p];
        }
        count += C[p];
        c[i] = m[i].size();
        l[i] = count;
    }

    for(int i = 0; i < N; i++) {

        ll count = (K / c[i]) * l[i];
        count += m[i][K % c[i]];
        ans = max(ans, count);

        count = K / c[i];
        if(count >= 1) {
            count--;
            count *= l[i];
            count += m[i][c[i] - 1];
            ans = max(ans, count);
            ans = max(ans, m[i][c[i] - 1]);
        } else {
            ans = max(ans, m[i][K]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 218904
#include <stdio.h>

typedef unsigned long long ull;

ull slime_combine(ull *a, size_t N) {
    ull sz[N][N], cost[N][N], tmp;
    size_t i, j, k, l;
    for (i = 0 ; i<N ; i++) {
        sz[i][i] = a[i];
        cost[i][i] = 0;
    }
    for (l = 1 ; l<N ; l++)
        for (i = 0, j = l ; j<N ; i++, j++) {
            cost[i][j] = cost[i+1][j] + a[i] + sz[i+1][j];
            sz[i][j] = a[i] + sz[i+1][j];
            for (k = i+1 ; k<j ; k++) {
                tmp = cost[i][k] + cost[k+1][j] + sz[i][k] + sz[k+1][j];
                if (tmp<cost[i][j]) cost[i][j] = tmp;
            }
        }
    return cost[0][N-1];
}

int main() {
    unsigned N;
    scanf("%u", &N);
    ull a[N];
    for (unsigned i = 0 ; i<N ; i++) scanf("%llu", a+i);
    printf("%llu", slime_combine(a, N));
    return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
 
void swap(int* a,int* b){
  int tmp=*a;
  *a=*b;
  *b=tmp;
}
 
int Partition(int A[],int p,int r){
  int x = A[r];
  int i=p-1,j;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}
 
int main(){
  int n,i,x;
  int A[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  x=Partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==x)printf("[");
    printf("%d",A[i]);
    if(i==x)printf("]");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2244
#include <bits/stdc++.h>
#define MAX 100000
using namespace std;

struct Process{
  char name[10];
  int time;
};
Process Q[MAX];
int head, tail;

void initialize();
bool isEmpty();
bool isFull();
void enqueue(Process);
Process dequeue();

int main() {
  int elaps = 0, c;
  int n, q;
  cin >> n >> q;

  initialize();

  for (int i = 0; i < n; i++) {
    Process a;
    cin >> a.name >> a.time;
    enqueue(a);
  }

  while (head != tail) {
    Process x = dequeue();
    if (x.time > q) {
      x.time -= q;
      enqueue(x);
      elaps += q;
    } else {
      elaps += x.time;
      cout << x.name << " " << elaps << endl;
    }
  }
}

void initialize() {
  head = tail = 0;
}

bool isEmpty() {
  return head == tail;
}

bool isFull() {
  return head == tail + 1;
}

void enqueue(Process x) {
  if (isFull()) cout << "Error: queue overflow" << endl;
  Q[tail++] = x;
  if (tail == MAX) tail = 0;
}

Process dequeue() {
  if (isEmpty()) cout << "Error: queue underflow" << endl;
  Process a = Q[head++];
  if (head == MAX) head = 0;
  return a;
}


Measured memory_bytes: 4656
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		long sum = 0;
		long ans = 0;
		for(int i=1; i<=x; i++) {
			sum += i;
			if(x<=sum) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}


}


Measured memory_bytes: 35788
import sys
from functools import reduce

n, m = map(int, input().split())
ps = [r.split() for r in sys.stdin.read().split('\n') if r != '']
log = []
for i in range(0, n):
    log.append([])
for j in range(0, m):
    i = int(ps[j][0])
    log[i-1].append(ps[j][1])
wacount = sum(map(lambda l: l.index('AC'), filter(lambda e: e.count('AC') > 0, log)))
print(len(list(filter(lambda e: e.count('AC') > 0, log))),
        wacount)

Measured memory_bytes: 45244
X = int(input())

kyu = 0
if 400 <= X <= 599:
  kyu = 8
elif 600 <= X <= 799:
  kyu = 7
elif 800 <= X <= 999:
  kyu = 6
elif 1000 <= X <= 1199:
  kyu = 5
elif 1200 <= X <= 1399:
  kyu = 4
elif 1400 <= X <= 1599:
  kyu = 3
elif 1600 <= X <= 1799:
  kyu = 2
elif 1800 <= X <= 1999:
  kyu = 1

  
  
print(kyu)

  
  

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

int main(){
  int n;
  cin >> n;
  vector<int> dn(n);
  for(int i=0; i<n; ++i) cin >> dn[i];
  sort(dn.begin(),dn.end());
  bool p = true;
  vector<int> ans(n+1);
  ans[0] = 0;
  for(int i=1; i<=n; ++i){
    ans[i] = (p ? dn[i-1]: 24 -dn[i-1]);
    p = (p ? false:true);
  }
  sort(ans.begin(),ans.end());
  int num = 24;
  for(int i=0; i<=n; ++i){
    if(i == n) num = min(num,24 - ans[n]);
    else{
      num = min(num, ans[i+1] - ans[i]);
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3604
function main()
  
  N = parse(Int,readline())
  A1 = map(x -> parse(Int,x), split(readline()))
  A2 = map(x -> parse(Int,x), split(readline()))
  
  ans = 0
  sum = 0
  
  for i in 1:N
    sum = 0
    for j in 1:i
      sum += A1[j]
    end
    for j in i:N
      sum += A2[j]
    end
    ans = max(ans,sum)
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 169620
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> v;

void solve(int n, int m){
  if(n == 0){
    for(vector<int>::iterator it = v.begin() ; it != v.end() ; it++){
      cout << *it;
      if(it == v.end()-1) cout << endl;
      else cout << " ";
    }
    return;
  }
  
  for(int i = m ; i > 0 ; i--){
    if(n - i >= 0){
      v.push_back(i);
      solve(n-i, i);
      v.pop_back();
    }
  }
}

int main(){
  int n;
  while(cin >> n, n){
    v.clear();
    solve(n, n);
  }
  return 0;
}

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

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

    unordered_set<string> T;

    for (int i = 0; i < n; i++) {
        string command, s;
        cin >> command >> s;
        if (command == "insert") {
            T.insert(s);
        }
        else if (command == "find") {
            bool f = T.count(s);
            if (f)
                cout << "yes" << endl;
            else
            {
                cout << "no" << endl;
            }
                }
    }
}


Measured memory_bytes: 31916
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 10;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
//const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ld n;
    cin >> n;
    n /= 3;
    cout << n * n * n << endl;
    return 0;
}

Measured memory_bytes: 256
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

using namespace std;
typedef long long ll;

int n, m;
vector<ll> x(1000), y(1000), z(1000);

ll calSum(int mulX, int mulY, int mulZ) {
    vector<ll> s(n);
    for (int i = 0; i < n; i++) s[i] = mulX * x[i] + mulY * y[i] + mulZ * z[i];
    sort(s.begin(), s.end());
    ll maxS = 0, minS = 0;
    for (int i = 0; i < m; i++) {
        maxS += s[n - i - 1];
        minS += -s[i];
    }
    return max(maxS, minS);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];

    ll ans = calSum(1, 1, 1);
    ans = max(calSum(-1, 1, 1), ans);
    ans = max(calSum(1, -1, 1), ans);
    ans = max(calSum(1, 1, -1), ans);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b,s;
	int k,k2;
	while(cin>>a>>b>>k>>k2>>s)
	{
		if(s==a) k--;
		else k2--;
		cout<<k<<" "<<k2<<"\n";
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n ,i ,total;
  while( scanf( "%d" ,&total ) ){
    if( total == 0 ){
      break;
    }
    
    for( i=0 ; i<9 ; i++ ){
      scanf( "%d" ,&n );
      total = total - n;
    }
    
    printf( "%d\n" ,total );
  }

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int count;
  
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    count = count + (r - l + 1);
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
<?php
$input = trim(fgets(STDIN));
List($a, $b) = explode(" ", $input);

while(($a + $b) > 0) {

  if ($a < $b) {
    echo "{$a} {$b}".PHP_EOL;
  } else {
    echo "{$b} {$a}".PHP_EOL;
  }

  $input = trim(fgets(STDIN));
  List($a, $b) = explode(" ", $input);
}

Measured memory_bytes: 15396
n=int(input())
a=[0,0,0,0,0]
for i in range(n):
    b=input()[0]
    if b=='M':
        a[0]+=1
    if b=='A':
        a[1]+=1
    if b=='R':
        a[2]+=1
    if b=='C':
        a[3]+=1
    if b=='H':
        a[4]+=1
b=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            b+=a[i]*a[j]*a[k]
print(b)

Measured memory_bytes: 3064
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  ll x;
  cin >> x;
  ll a, b;
  int ans1 = 0;
  int ans2 = 0;

  for (int i = -119; i <= 119; i++) {
    for (int j = -119; j <= 119; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        ans1 = i;
        ans2 = j;
        break;
      }
    }
  }
  cout << ans1 << " " << ans2;
  return 0;
}


Measured memory_bytes: 4088
#include <iostream>
#include <algorithm>

using namespace std;

void solve() {
    string O, E;
    char str[101];
    cin >> O;
    cin >> E;
    int i = 0, l;
    for (char c: O) {
        str[i] = c;
        i += 2;
    }
    str[i] = 0;
    i = 1;
    for (char c: E) {
        str[i] = c;
        i += 2;
    }
    str[i]=0;
    cout << str << endl;

}

int main() {

    solve();
    return 0;
}


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

int main(void)
{
	int n;
	scanf("%d\n",&n);
	int a[n];
	int b[n];
	int i;
	for (i=0;i<n;i++){
		scanf("%d ",&a[i]);
		b[i]=-1;
	}
	int j=0;
	for (i=n-1;i>=0;i-=2){
		b[j]=a[i];
		j++;
	}
	if ((n%2)==0)i=0;
	else i=1;
	for (;i<=n-1;i+=2){
		b[j]=a[i];
		j++;
	}
	for (i=0;i<n;i++){
		if (i!=0)printf(" ");
		printf("%d",b[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
const int Maxn=105;
int f[Maxn][Maxn][Maxn],g[Maxn][Maxn][Maxn],C[Maxn][Maxn];
int main(){
    int n,m,c,mod;cin>>n>>m>>c>>mod;
    for(int i=0;i<105;C[i++][0]=1)
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
    f[0][0][0]=1;
    for(int k=1;k<=c;k++){
        static int base[Maxn*Maxn];
        for(int i=0,w=1;i<=n*m;i++,w=1ll*w*(c-k+1)%mod)base[i]=w;
        for(int j=m,b1=1,b2=1;j>=0;j--,b1=1ll*b1*k%mod,b2=1ll*b2*(k-1)%mod)
            for(int i=0;i<=n;i++)
                for(int d=0,w=1;i+d<=n;d++,w=1ll*w*(b1-b2)%mod)
                    g[i+d][j][k]=(g[i+d][j][k]+1ll*f[i][j][k-1]*C[n-i][d]%mod*base[d*j]%mod*w)%mod;
        for(int i=0,w=1;i<=n*m;i++,w=1ll*w*k%mod)base[i]=w;
        for(int i=0,b1=1,b2=1;i<=n;i++,b1=1ll*b1*(c-k+1)%mod,b2=1ll*b2*(c-k)%mod)
            for(int j=0;j<=m;j++)
                for(int d=0,w=1;j+d<=m;d++,w=1ll*w*(b1-b2)%mod)
                    f[i][j+d][k]=(f[i][j+d][k]+1ll*g[i][j][k]*C[m-j][d]%mod*base[(n-i)*d]%mod*w)%mod;
    }
    cout<<(f[n][m][c]+mod)%mod<<"\n";
    return 0;
}

Measured memory_bytes: 9216
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	long long int a[300001];
	for(int i = 0; i < 3 * n; i++){
		cin >> a[i];
	}
	sort(a, a + 3 * n);
	int now = 3 * n - 2;
	long long int ans = 0;
	for(int i = 0; i < n; i++){
		ans += a[now];
		now -= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n,x,t; cin>>n>>x>>t;
	ll a = n/x; ll b=n%x;
	if(b!=0)a++;
	cout<<(a*t);
	return 0;
}

Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	k := len(s)
	m := map[byte]int{}
	for i := 0; i < 15; i++ {
		if i < k {
			m[s[i]] = m[s[i]] + 1
			continue
		}
		m['o'] = m['o'] + 1
	}
	if m['o'] >= 8 {
		fmt.Fprintln(writer, "YES")
		return
	}
	fmt.Fprintln(writer, "NO")
}


Measured memory_bytes: 640
A,B=map(int,input().split())
cnt=0
for i in range(A,B+1):
    i=str(i)
    if len(i)%2==0:
        if i[0:(len(i)/2)]==(i[(len(i)/2):])[::-1]:
            cnt+=1
        else:
            continue
    elif len(i)%2!=0:
        if i[0:(len(i)//2)+1]==(i[(len(i)//2):])[::-1]:
            cnt+=1
        else:
            continue
    else:
        continue
print(cnt)
                

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

int n, cnt;
string s;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> s;
	n = s.length();
	for (int i = 0; i < n; ++i)
		if (s[i] == 'o')
			++cnt;

	if (cnt + 15 - n >= 8)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 101

int size[MAX],p[MAX],roll[MAX][MAX];
void GVE(int c,int v);

int main(){
  int i,j,n,m;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    p[i]=10000;
    for(j=1;j<=n;j++){
      roll[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    scanf("%d",&m);
    scanf("%d",&size[m]);
    for(j=1;j<=size[m];j++){
      scanf("%d",&roll[m][j]);
    }
  }
  GVE(1,0);
  for(i=1;i<=n;i++){
    if(p[i]==10000){
      p[i]=-1;
    }
    printf("%d %d\n",i,p[i]);
  }
  return 0;
}

void GVE(int c,int v){
  int i;
  p[c]=v;
  for (i=1;i<=size[c];i++){
    if (p[roll[c][i]]>v){
      GVE(roll[c][i],v+1);
    }
  }
}



Measured memory_bytes: 2060
import sys

n = int(sys.stdin.readline())
w = list(map(int, sys.stdin.readline().split()))
c = [False]*n
u = sorted(w)
cost = 0
while False in c:
    i = c.index(False)
    c[i] = True
    i0=i
    llen=1
    lmin=w[i]
    while True:
        i = u.index(w[i])
        if c[i]: break
        c[i] = True
        llen+=1
        if lmin > w[i]: lmin = w[i]
        cost += w[i]

    if llen>1:
        cost += w[i0]+min(lmin+(llen+1)*min(w), lmin*(llen-2))

print(cost)


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  int ans = n / 3;
  cout << ans << endl;
}

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

int main() {
	string N;
	cin >> N;
	int flag = 0;
	for (int i = 0; i < (int)N.size(); i++) {
		if (N.at(i) == '7') {
			flag = 1;
		}
	}
	if (flag == 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**6)
def dfs(G,v,p,color):
    cnt=1
    for nv in G[v]:
        if(nv==p):
            continue
        while(cnt in s[v]):
                cnt+=1
        s[v].add(cnt)
        s[nv].add(cnt)
        dic[tuple(sorted([v,nv]))]=cnt
        dfs(G,nv,v,cnt)
        
N=int(input())
G=[[] for i in range(N)]
e=[]
s=[set() for i in range(N)]
dic={}
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
    e.append(sorted([a,b]))
l=0
for i in range(N):
    l=max(l,len(G[i]))
dfs(G,0,-1,0)
print(l)
for i in range(N-1):
    print(dic[e[i][0],e[i][1]])

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 110;


int n;
string s;
int k;

ll cache[maxn][5][3][3];

ll dfs(int i, int nonz, bool lower, bool f) {
  if (nonz > k) return 0;
  if (i == n) {
    return (nonz == k);
  } else {
    if (cache[i][nonz][lower][f] != -1) {
      return cache[i][nonz][lower][f];
    }
    ll res = 0;
    int dig = s[i]-'0';
    for (int d=(f ? 1: 0); d<=(lower ? 9 : dig); d++) {
      res += dfs(i + 1, nonz + (d>0), lower || (d<dig), false);
    }
    return cache[i][nonz][lower][f] = res;
  }
}

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

  memset(cache, -1, sizeof cache);
  
  cin>>s>>k;
  n = s.length();
  ll ans = 0;

  for (int i=0; i<n; i++) {
    ans += dfs(i, 0, i>0, true);
  }

  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int64_t k;
	std::cin >> k;

	constexpr int64_t N = 50;

	int64_t a[N] = {};
	for (auto&& e : a)
		e = N - 1 + k / N;

	k %= N;

	for (int i = 0; i < k; ++i)
		a[i] += N - k + 1;

	for (int i = k; i < N; ++i)
		a[i] -= k;

	std::cout << N << std::endl;
	std::cout << a[0];
	for (int i = 1; i < N; ++i)
		std::cout << " " << a[i];

	std::cout << std::endl;
}

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

int main(){
	int n,m,X,Y;
	cin >> n >> m >> X >> Y;
	int mx = -101;
	int my = 101;
	rep(i,n){
        int x;
		cin >> x;
		mx = max(mx,x);
	}
    rep(i,n){
        int y;
        cin >> y;
		my = min(my,y);
	}
    int z = min(X+1,mx);
    for(z;z <= min(Y,my);z++){
        if(X < z && mx < z && z <= Y && z <= my){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    ll k,n,maxi=-100000000000;
    cin>>k>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    maxi=a[0]+k-a[n-1];
    rep(i,n-1){
        maxi=max(maxi,a[i+1]-a[i]);
    }
    cout<<k-maxi<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>

using namespace std;

set<int> prime;

void calc_prime(int mm) {
    int cur = 2;
    while(cur <= mm) {
        for(auto itr = prime.begin();itr != prime.end();itr++) {
            if(cur % *itr == 0)
                goto not_prime;
        }
        prime.insert(cur);
    not_prime:
        cur++;
    }
}
/*
int main(void) {
    string s;
    int w;
    cin >> s;
    cin >> w;
    for(int i = 0;i < s.length();i = i + w) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}
*/
int main(void) {
    double n,m,d;
    cin >> n >> m >> d;
    double res = (n - d) * (m - 1) / (n * n);
    if(d != 0)
        res = res * 2.0;
    cout << setprecision(12) << res;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;



int n,k;
ll h[100111];
ll dp[100111];
bool dpf[100111];

int main(){
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)scanf("%lld",&h[i]);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(dpf[i+j])dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
            else{
                dp[i+j]=dp[i]+abs(h[i]-h[i+j]);
                dpf[i+j]=true;
            }
        }

        
    }
    printf("%lld\n",dp[n-1]);
    
}


Measured memory_bytes: 1920
#include<stdio.h>
#include<stdlib.h>

#define MAX 10000

int main(void){
  
  int C[MAX];
  int n;
  int i,j;
  unsigned short *A,*B;
  
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n + 1);
  B = malloc(sizeof(short)*n + 1);
  
  for(i = 0;i < MAX;i++){
    C[i] = 0;
  }
    
  for(i = 0;i < n;i++){
    scanf("%hu",&A[i+1]);
    C[ A[i+1] ]++;
  }

  for(i = 1;i <= MAX;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j = 1;j <= n;j++){
    B[ C[A[j]] ] = A[j];
    C[A[j]]--;
  }

  for(i = 1;i <= n;i++){
    if(i != 1){
      printf(" ");
    }
    printf("%d",B[i]);
  }
  printf("\n");

  free(A);
  free(B);

  return 0;
}
      



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

const int INF=1e9;
typedef long long ll;
typedef pair<int,int> P;

ll N,W; 
P wv[105];
vector<int> v[5];
ll cnt[5][105];
  
int main(){
 
cin>>N>>W;

int Min=INF;
for(int i=0; i<N; i++){
    scanf("%d %d",&wv[i].first,&wv[i].second); Min=min(Min,wv[i].first);
}

for(int i=0; i<N; i++){
    if(wv[i].first==Min){
        v[0].push_back(wv[i].second);
    }
    if(wv[i].first==Min+1){
        v[1].push_back(wv[i].second);
    }
    if(wv[i].first==Min+2){
        v[2].push_back(wv[i].second);
    }
    if(wv[i].first==Min+3){
        v[3].push_back(wv[i].second);
    } 
}

sort(v[0].begin(),v[0].end()); reverse(v[0].begin(), v[0].end());
sort(v[1].begin(),v[1].end()); reverse(v[1].begin(), v[1].end());
sort(v[2].begin(),v[2].end()); reverse(v[2].begin(), v[2].end());
sort(v[3].begin(),v[3].end()); reverse(v[3].begin(), v[3].end());

for(int i=0; i<v[0].size(); i++) cnt[0][i+1]=cnt[0][i]+v[0][i];
for(int i=0; i<v[1].size(); i++) cnt[1][i+1]=cnt[1][i]+v[1][i];
for(int i=0; i<v[2].size(); i++) cnt[2][i+1]=cnt[2][i]+v[2][i];
for(int i=0; i<v[3].size(); i++) cnt[3][i+1]=cnt[3][i]+v[3][i];

ll w0=Min,w1=w0+1,w2=w1+1,w3=w2+1; ll Max=0LL;

for(ll l=0; l<=N; l++){
    if(l*w0>W) continue;
    for(ll k=0; k<=N; k++){
        if(l*w0+k*w1>W) continue;
        for(ll i=0; i<=N; i++){
            if(l*w0+k*w1+i*w2>W) continue;
            for(ll j=0; j<=N; j++){
                if(l*w0+k*w1+i*w2+j*w3>W) continue;
                //cout<<l*w0<<" "<<k*w1<<" "<<i*w2<<" "<<j*w3<<endl;
                //cout<<l*w0<<" "<<k*w1<<" "<<i*w2<<" "<<j*w3<<endl;
                Max=max(Max,cnt[0][l]+cnt[1][k]+cnt[2][i]+cnt[3][j]);
            }
        }
    }
}

cout<<Max<<endl;

}

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

typedef long long ll;
typedef  pair<ll, ll> pii;

ll H, W, N;
ll A[100000], B[100000];
set<pii> coord, S;
ll ans[100];

void make(ll y, ll x) {
   for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
         int ny = y - i, nx = x - j;
         if (ny >= 1 && ny <= H-2 && nx >= 1 && nx <= W-2) {
            S.insert({ny, nx});
         }
      }
   }
}


int main() {
   cin >> H >> W >> N;
   for (int i = 0; i < N; i++) {
      cin >> A[i] >> B[i];
      coord.insert({A[i], B[i]});
      make(A[i], B[i]);
   }

   ll white = (H-2) * (W-2);
   for (pii p : S) {
      ll y = p.first, x = p.second;
      int cnt = 0;
      for (ll i = y; i < y+3; i++) {
         for (ll j = x; j < x+3; j++) {
            if (coord.find({i, j}) != coord.end()) {
               cnt++;
            }
         }
      }
      if (cnt) white--;
      ans[cnt]++;
   }

   ans[0] = white;
   for (int i = 0; i <= 9; i++) {
      cout << ans[i] << endl;
   }


   return 0;
}


Measured memory_bytes: 64256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_129
{
    class E
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string s = Read();
            long mask = 1000000000 + 7;
            long res = 0;
            long onCnt = 0;
            long remainPats = 1;
            long allPats = 1;
            for(int i = 0; i < s.Length; i++)
            {
                allPats *= 3;
                allPats %= mask;
            }
            
            for(int i = 0; i <s.Length; i++)
            {
                allPats = MultiMod(allPats, ReverseMod(3, mask - 2, mask), mask);
                if (s[i] != '1') continue;

                res+= MultiMod(allPats, remainPats, mask);
                res %= mask;
                onCnt++;
                remainPats *= 2;
                remainPats %= mask;
            }
            res += remainPats;
            res %= mask;

            WriteLine(res);
        }

        static long MultiMod(long a, long b, long mask)
        {
            return ((a % mask) * (b % mask)) % mask;
        }

        static long ReverseMod(long a, long pow, long mask)
        {
            if (pow == 0) return 1;
            else if (pow == 1) return a % mask;
            else
            {
                long halfMod = ReverseMod(a, pow / 2, mask);
                long nextMod = MultiMod(halfMod, halfMod, mask);
                if (pow % 2 == 0)
                {
                    return nextMod;
                }
                else
                {
                    return MultiMod(nextMod, a, mask);
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11360
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,cnt;

int main(){

  cin >> n;
  rep(i,1,n+1) if(i%2==1) {
    int a=0;
    rep(j,1,n+1) if(i%j==0)a++;
    if(a==8)cnt++;
  }
  cout << cnt << endl;

  return 0;
}


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

int main(){ 
  string S1, S2; cin >> S1 >> S2;
  bool flag = true;
  if (S1[0] != S2[2]) flag = false;
  if (S1[1] != S2[1]) flag = false;
  if (S1[2] != S2[0]) flag = false;
  
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }

int main(){
    int n;
    in(n);
    vector<int> vec(n);
    in(vec);
    //偶数番目と奇数番目についてそれぞれの出現回数をカウント
    //最多の数字が被っていた場合その次点で多いものを採用
    //nが奇数の場合，奇数番目がn/2+1，偶数番目がn/2
    vector<int> odd(100001,0),even(100001,0);
    int maxodd=0,maxeven=0;
    int oddnum,evennum;
    for(int i=0;i<n;i++){
        if(i%2==0){
            odd[vec[i]]++;
            if(odd[vec[i]]>maxodd){
                maxodd=odd[vec[i]];
                oddnum=vec[i];
            }
        }else{
            even[vec[i]]++;
            if(even[vec[i]]>maxeven){
                maxeven=even[vec[i]];
                evennum=vec[i];
            }
        }
    }
    debug(maxodd,maxeven);
    if(oddnum!=evennum){
        out(n-maxeven-maxodd);
    }else{
        if(n>=4){
            sort(rall(odd));
            sort(rall(even));
            out(min(n-odd[0]-even[1],n-odd[1]-even[0]));
        }else{
            if(n==3)out(2);
            if(n==2)out(1);
        }
    }
}

Measured memory_bytes: 4672
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N;
vector<pair<ll, ll> > a;
ll result[100010];

int main(){
  cin >> N;
  for(ll i = 1; i <= N; i++){
    int x;
    cin >> x;
    a.push_back(pair<ll, ll> (x, i));
  }
  fill(result, result+N+1, 0);

  sort(a.begin(), a.end(), greater<pair<ll, ll> >() );

  ll cur;
  ll next;
  for(cur = 0; cur < N && a[cur].first == a[cur+1].first; cur++){
    ;
  }
  ll cur_point = cur;

  while(1){
    for(next = cur_point + 1; next < N && a[next].first == a[next+1].first; next++){
      ;
    }

    if(next < N){
      result[a[cur].second] += (a[cur_point].first - a[next].first)*(cur_point+1);
      if(a[cur].second > a[next].second) cur = next;
      cur_point = next;
    }
    else{
      result[a[cur].second] += (a[cur_point].first) * (cur_point+1);
      break;
    }
  }

  for(ll i = 1; i <= N; i++){
    cout << result[i] << endl;
  }

  return 0;

}


Measured memory_bytes: 3568
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int H[] = new int[N];

        int res = 1, min = 0;
        Arrays.setAll(H, i -> scanner.nextInt());

        for (int i = 1; i < N; i ++) {
            if (H[i] >= H[min]) {
                res ++;
                min = i;
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 28500
#! /usr/bin/perl

use strict;
use warnings;

chomp(my $buf = <>);
my($max, $a, $b) = split(/\s+/, $buf);

my $total = 0;
for my $n (1 .. $max) {
    my $sum = 0;
    foreach my $c (split(//, $n)) {
        $sum += $c;
    }
    if($a <= $sum && $sum <= $b) {
        $total += $n;
    }
}
print $total, "\n";


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int main(){
  int count=0;
  string needle = "";
  string word = "";
  cin>>needle;
  while(cin>>word , word != "END_OF_TEXT"){
    for(int i=0;i<(int)word.size();i++)
      word[i] = tolower(word[i]);
    if(word == needle) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 1196
import java.util.*;
class Main{
        public static boolean judge(int y){
                if(y%3==0)      return true;
                return false;
        }
        public static int days(int y,int m,int d){
                int days = 0;
                for(int i=1;i<y;i++){
                        if(i%3==0){
                                days += 200;
                        }else{
                                days += 195;
                        }
                }
                if(y%3!=0){
                        for(int i=1;i<m;i++){
                                if(i%2==0)days+=19;
                                else days += 20;
                        }
                }else{
                        for(int i=1;i<m;i++){
                                days += 20;
                        }
                }
                days += d;
                return days;
        }
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int today = days(1000,1,1);
                int n=sc.nextInt();
                for(int i=0;i<n;i++){
                        int ans = today - days(sc.nextInt(),sc.nextInt(),sc.nextInt());
                        System.out.println(ans);
                }

        }
}

Measured memory_bytes: 20612
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    double n;
    cin>>n;
    int ans;
    for(int i=n;i>=0;i--){
        if(floor(sqrt(i))==ceil(sqrt(i))){ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    N, W = map(int, input().split())
    V = [[0] for _ in range(4)]
    for i in range(N):
        w, v = map(int, input().split())
        if i == 0:
            init = w
        V[w - init].append(v)

    for i in range(4):
        V[i].sort(reverse=True)

    res = 0
    for i in range(len(V[0]) + 1):
        a = sum(V[0][:i])
        for j in range(len(V[1]) + 1):
            b = sum(V[1][:j])
            for k in range(len(V[2]) + 1):
                c = sum(V[2][:k])
                for l in range(len(V[3]) + 1):
                    d = sum(V[3][:l])
                    total_w = init * i + (init + 1) * j + (init + 2) * k + (init + 3) * l
                    if total_w <= W:
                        res = max(res, a + b + c + d)
    print(res)


if __name__ == '__main__':
    resolve()


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

using namespace std;

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

  vector<array<int, 3>> vt(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> vt[i][0] >> vt[i][1] >> vt[i][2];
  }

  for (int i = 0; i < vt.size(); ++i) {
    int cur = i, t = 0;
    while (cur < vt.size()) {
      // cur -> cur + 1
      int c, f, s;
      c = vt[cur][0];
      s = vt[cur][1];
      f = vt[cur][2];

      if (s > t) {
        t = s;
      } else if (t % f != 0) {
        t = t + (f - t % f);
      }

      t += c;

      cur++;
    }

    cout << t << '\n';
  }

  cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 3640