akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int cnt(0);
  for(int i(0);i<N;i++){
    if(s[i] == '1') cnt++;
  }
  int kouho1(cnt+1),kouho2(cnt-1);
  //cout << cnt << " " << endl;
  int amari1[200001] = {0},amari2[200001] = {0};
  //int tmp1(1),tmp2(1);
  amari1[0] = 1%kouho1;
  if(kouho2 != 0) amari2[0] = 1%kouho2;

  for(int i(1);i<N;i++){
    amari1[i] = (amari1[i-1]*2)%kouho1;
    if(kouho2 != 0) amari2[i] = (amari2[i-1]*2)%kouho2;
  }
  int x1(0),x2(0);
  for(int i(0);i<N;i++){
    if(s[i] == '1'){
      x1 += amari1[N-i-1];
      x2 += amari2[N-i-1];
      x1 %= kouho1;
      if(kouho2 != 0) x2 %= kouho2;
    }
  }
  //cout << x1 << ' '<<x2 << endl;
  for(int i(0);i<N;i++){
    // 一回余り求める
    int x;
    int t1 = x1,t2 = x2;
    int tmp(1);
    if(s[i] == '1'){
      if(kouho2 == 0){
        cout << 0 << endl;
        continue;
      }
      t2 -= amari2[N-i-1];
      if(t2 < 0) t2+= kouho2;
      x = t2;
    }else{
      t1 += amari1[N-i-1];
      t1 %= kouho1;
      x = t1;
    }
    //cout<< "x:" << x << endl;
    while(x != 0){
      tmp++;
      x = x%(__builtin_popcount(x));
    }
    cout << tmp << endl;
  }
  return 0;
}



Measured memory_bytes: 5300
import string
abc = string.ascii_lowercase
s = list(input())
K = int(input())
index = 0
while K > 0:
    if index == len(s) - 1:
        s[index] = abc[(abc.index(s[index]) + K) % 26]
        break
    tmp = 26 - abc.index(s[index])
    if tmp == 26:
        index += 1
        continue
    if K >= tmp:
        s[index] = 'a'
        index += 1
        K -= tmp
    else:
        index += 1

for i in s:
    print(i, end='')

Measured memory_bytes: 10884
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int H1, M1, H2, M2, k;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> H1 >> M1 >> H2 >> M2 >> k;
	ll deg = H1 * 60 + M1;
	ll deg2 = H2 * 60 + M2;
	deg2 -= deg;
	deg2--;
//	cout << deg2 << '\n';
	cout << max(0ll, deg2 - k + 1);












	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  string ans;
  rep(i, n) {
    ans += s.substr(i, 1);
    ans += t.substr(i, 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3540
integer N
integer(16),allocatable,dimension(:)::A
integer(16) Asum,ans,preans
read*,N
allocate(A(N))
read*,A

Asum=0;preans=0
do i=1,N
  Asum=Asum+A(i)
  select case(mod(i,2))
    case(1)
      if(Asum<=0)then
        preans=preans+abs(1-Asum)
        Asum=1
      endif
    case(0)
      if(Asum>=0)then
        preans=preans+abs(-1-Asum)
        Asum=-1
      endif
  end select
end do
ans=preans
Asum=0;preans=0
do i=1,N
  Asum=Asum+A(i)
  select case(mod(i,2))
    case(0)
      if(Asum<=0)then
        preans=preans+abs(1-Asum)
        Asum=1
      endif
    case(1)
      if(Asum>=0)then
        preans=preans+abs(-1-Asum)
        Asum=-1
      endif
  end select
end do
ans=min(ans,preans)
print"(i0)",ans
end

Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
int main() {
	char n[100];
	scanf("%s", &n);
	int len = strlen(n);
	if (n[len - 1] == '3') {
		printf("bon\n");
	} else if (n[len - 1] == '0' || n[len - 1] == '1' || n[len - 1] == '6' ||
			   n[len - 1] == '8') {
		printf("pon\n");
	} else {
		printf("hon\n");
	}
	return 0;
}

Measured memory_bytes: 1656
def calc_circle(r):
    pi = 3.14159265359
    area = round(r*r*pi, 6)
    circ = round(2*r*pi, 6)

    return (area, circ)


if __name__ == "__main__":
    r = float(input())
    area, circ = calc_circle(r)
    print(f"{area:.6f} {circ:.6f}")




Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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;string s;
  cin >> n >> s;
  int m = 0,d = 0;
  rep(i,n){
    if(s[i]=='(') ++d;
    else --d;
    m = min(m,d);
  }
  rep(i,-m) cout << '(';
  cout << s;
  rep(i,d-m) cout << ')';
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    string s;
    cin >> s;
    if(s[0] == '1'){
        s[0] = '9';
    }else if(s[0] == '9'){
        s[0] = '1';
    }
    if(s[1] == '1'){
        s[1] = '9';
    }else if(s[1] == '9'){
        s[1] = '1';
    }
    if(s[2] == '1'){
        s[2] = '9';
    }else if(s[2] == '9'){
        s[2] = '1';
    }
    cout << s << endl;
}

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

using ll = long long;
#define rep(i,a,b) for(auto i = (a); i < (b); ++i)

const int MOD = 1000000007;
const int inv2 = 500000004;
auto add(auto a, auto b){return ((ll) a + b) % MOD;}
auto sub(auto a, auto b){return ((ll) a - b + MOD) % MOD;}
auto mult(auto a, auto b){return (ll) a * b % MOD;}
auto sum(auto a, auto b) { // inclusive
  auto gap = (b - a + 1);
  auto res = add(mult(gap, a), mult(mult(gap, gap - 1), inv2));
  return res;
}

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

    int n, k;
    cin >> n >> k;
    ++n; // so we can work on range [1...n]
    auto res = 0LL;
    rep(taken, k, n + 1) {
      auto lo = sum(1, 1 + taken - 1);
      auto hi = sum(n - taken + 1, n);
      auto delta = add(sub(hi, lo), 1);
      res = add(res, delta);
    }
    cout << res << '\n';
    
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n; cin >> n;
    map<ll,int> mp;
    for(ll i=2;i*i<n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            mp[i]=res;
        }
    }
    if(n!=1) mp[n]++;
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        int p=itr->se; //cout << p << endl;
        p*=2;
        for(int i=1;i<=p;i++){
            if(i*(i+1)>p){
                //cout << i << endl;
                ans+=(i-1);
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void){
  long long N;
  cin >> N;
  
  long long ans =0;
  for(long long i=0;i<=N;i++){
    if(i % 3 != 0 && i % 5 != 0) ans += i;
  }

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=2100;
const ll inf=1e18;
int n,m,a[N]; ll ans;

const bool cmp(int x,int y){return a[x]<a[y];}

int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,n) scanf("%d",&a[i]),ans+=a[i];
	rep (i,1,n){ //i次轮换
		multiset<int> s;
		ll now=(ll)i*m;
		rep (j,1,i) s.insert(a[(n-j)%n+1]);
		rep (j,1,n){
			s.insert(a[j]);
			now+=*s.begin();
			s.erase(s.find(a[(j+n-i-1)%n+1]));
		}
		ans=min(ans,now);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

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

    long p = 1e9;
    if(s == 1e9) p = 1;

    for(int i=0; i<n; i++)
        cout << (i < k ? s : p) << ' ';
    cout << endl;

}


Measured memory_bytes: 1408
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	string t = ReadLine();
	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0])
	{
	    WriteLine("YES");
	}
	else
	{
	    WriteLine("NO");
	}
    }
}
	 


Measured memory_bytes: 13140
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    string s;

    cin >> s;

    int ans[30];
    for(int i=0;i<30;i++){
        ans[i] = 0;
    }
    for(int i=0;i<s.length();i++){
        ans[s[i] - 'a']++;
    }
    for(int i=0;i<26;i++){
        if(ans[i] ==0){
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
       
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long int LL;
const int maxn=101000;
int main()
{
    LL X,sum;
    scanf("%lld",&X);
    sum=100;
    for(int i=1;i;i++)
    {
        sum+=(sum*0.01);
        if(sum>=X)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


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

int main(){
  const int N= 3;
  vector<int64_t> data(N);
  bool is_even= false;
  for(int i=0; i<N; i++){
    cin >> data.at(i);
    if(data.at(i)%2==0){ is_even= true; }
  }
  sort(data.begin(), data.end());

  int64_t ans= (is_even) ? 0
                         : data.at(0)* data.at(1);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//結局全探索、たかだか2^10-1通りなので
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    int F[N][10];
    ll P[N][11];
    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < 10; ++j) cin >> F[i][j];
    
    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < 11; ++j) cin >> P[i][j];
    
    ll res = -1e9;
    int cnt[N];
    for(int cs = 1; cs < (1<<10); ++cs) {
        fill(cnt, cnt + N, 0);
        ll tmp = 0;
        for(int i = 0; i < 10; ++i) {
            if(cs & (1 << i)) {
                for(int j = 0; j < N; ++j)
                    if(F[j][i]) ++cnt[j];
            }
        }

        for(int i = 0; i < N; ++i) tmp += P[i][cnt[i]];
        res = max(res, tmp);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

int main(int argc, char *argv[])
{
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B)  << " " << max(A + B - N, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int a,b;
  cin>>a>>b;
  int ans=0,cnt=1;
  while(cnt<b)
  {
    cnt--;
    cnt+=a;
    ans++;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int max = 0;
        for (int i = 0; i <= s.length() - t.length(); i++) {
            int cnt = 0;
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i + j) == t.charAt(j)) {
                    cnt++;
                }
            }
            max = Math.max(max, cnt);
        }
        System.out.println(t.length() - max);
    }
}

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


int A[2000002],B[2000002];
int C[10001];
int n;
void Counting_Sort(int A[], int B[], int n);

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){

    scanf("%d",&A[i]);

}
  Counting_Sort(A, B, 10000);

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

  return 0;
}


void Counting_Sort(int A[],int B[],int k){
  int i,j;
  for(i=0;i<=k;i++){
    C[i]=0;
  }

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

 return;
}

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

int main() {

	ll k; cin >> k;
	ll a = 7;
	ll ans = -1;
	for (int i = 1; i <= k + 3; i++) {
		if (a % k == 0) {
			ans = i;
			break;
		}
		a = a * 10 + 7;
		a %= k;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define N 100009
using namespace std;

int n,ans,tot,fst[N],pnt[N<<1],nxt[N<<1],fa[N],tg[N];
void add(int x,int y){
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
void dfs(int x){
	int i,j,tmp,y;
	for (i=fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (y!=fa[x]){
			fa[y]=x; dfs(y);
			tmp=tg[x]&tg[y];
			for (j=1; j<=tmp; j<<=1) tg[x]|=j;
			tg[x]|=tg[y];
		}
	}
	for (i=1; tg[x]&i; i<<=1) tg[x]^=i;
	tg[x]|=i;
	ans=max(ans,tg[x]);
}
int main(){
	scanf("%d",&n);
	int i,x,y;
	for (i=1; i<n; i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	dfs(1);
	for (i=-1; ans; ans>>=1) i++;
	printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 6400
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
//{{{ read()
inline ll read(){
	register ll x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int P=1e9+7;
const int N=305;
ll fac[N],inv[N],f[N][2];
ll fsp(ll x,int y=P-2){
	ll ans=1;
	while(y){
		if(y&1)	ans=ans*x%P;
		x=x*x%P,y>>=1;
	}
	return ans;
}
int n,d[N],ans;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++)	d[i]=read();
	for(int i=1;i<=n;i++){
		fac[i]=fac[i-1]*i%P;
		inv[i]=fsp(fac[i]);
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=i;~j;j--){
			f[j][0]=f[j][0]*inv[d[i]-1]%P;
			f[j][1]=f[j][1]*inv[d[i]-1]%P;
			if(d[i]>1&&j){
				f[j][0]=(f[j][0]+f[j-1][0]*inv[d[i]-2])%P;
				f[j][1]=(f[j][1]+f[j-1][1]*inv[d[i]-2])%P;
			}
			if(d[i]>2)	f[j][1]=(f[j][1]+f[j-1][0]*inv[d[i]-3])%P;
		}
	}
	for(int i=3;i<n;i++)	ans=(ans+f[i][1]*fac[n-i-1]%P*fac[i-1]%P*inv[2])%P;

	int flag=1;
	for(int i=1;i<=n;i++)
		if(d[i]<2)	flag=0;
	if(flag)	ans=(ans+fac[n-1]*inv[2])%P;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
/**
 * @brief  0-1ナップサック問題(0-1 knapsack problem)は次の問題である
 *
 *         泥棒がある店に盗みに入ってn個の品物を見つけた. i番目の品物はviドルの価値があり、重さはwiポンドである
 *         ただし、viとwiは整数である. 彼はできるだけ高価な品物を盗りたいが、彼のナップサックでは高々Wポンド(Wは整数)の荷物しか運べない
 *
 *         各品物は盗るか残すかのどちらかなので、この問題は0-1ナップサック問題と呼ばれる
 *         この泥棒は品物の一部だけを盗ったり、同じものを複数回盗ることはできない
 *
 * @note   n個の各品物について、「盗る」か「残す」かの組み合わせをすべて調べるアルゴリズムの計算効率はΟ(2^n)となってしまい、　
 *         大きな入力nに対して解くことができないが、品物の大きさw, ナップサックの大きさWがともに整数であれば、
 *         0-1ナップサック問題は動的計画法によりΟ(nW)の計算効率で厳密解を求めることができる
 *
 * @note   次のような変数を用意する
 *
 *           v[n+1]       i番目の品物の価値が記録されている1次元配列
 *           w[n+1]       i番目の品物の重さが記録されている1次元配列
 *           C[n+1][W+1]  i個目までの品物を考慮して大きさjのナップサックに入れる場合の価値の合計の最大値をC[i][j]とする2次元配列
 *
 *         考慮する品物の数i, 各iにおけるナップサックの重さjを増やしていき、C[i][j]を変更していく. C[i][j]の値は、
 *
 *           1. C[i - 1][j - 品物iの重さ] + 品物iの価値
 *           2. C[i - 1][j]
 *
 *         の大きい方となる. ここで1.はこの時点で品物iを盗る、2.はこの時点で品物iを残す、という処理に対応する
 *         ただし、1.の場合は、品物iの重さがjを超えない場合に限る
 *
 * @date   2016/05/05
 */



//********************************************************************************
// 必要なヘッダファイルのインクルード
//********************************************************************************

#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>



//********************************************************************************
// 型シノニム
//********************************************************************************

using index_t  = std::int_fast32_t;
using value_t  = std::int_fast32_t;
using weight_t = std::int_fast32_t;

using indices_t = std::vector<index_t>;
using values_t  = std::vector<value_t>;
using weights_t = std::vector<weight_t>;

using dptbl_t   = std::vector<values_t>;



//********************************************************************************
// 関数の定義
//********************************************************************************

/**
 * @brief  動的計画法を用いて0-1ナップサック問題(0-1 knapsack problem)を解きます
 *
 * @param  const value_t& v i番目の品物の価値が記録されている1次元配列v
 * @param  const value_t& w i番目の品物の重さが記録されている1次元配列w
 * @param  weight_t       W ナップサックに詰めこめる最大の重さW
 */
value_t __01_knapsack__(const values_t& v, const weights_t& w, weight_t W)
{    
    index_t n = v.size();              // n = v.length
    dptbl_t C(n+1, values_t(W+1, 0));  // Cを(n+1) x (W+1)型の新しい行列とする

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

        for (weight_t j = 1; j <= W; j++) {

            if (w[i] <= j) {
                C[i][j] = std::max(C[i - 1][j - w[i]] + v[i], C[i - 1][j]);
            }
            else {
                C[i][j] = C[i - 1][j];
            }
        }
    }
    
    return C[n][W];
}



//********************************************************************************
// エントリポイント
//********************************************************************************

int main()
{
    using namespace std;

    int n, W;
    cin >> n >> W;
    
    values_t  v(n + 1);
    weights_t w(n + 1);

    for (int i = 1; i <= n; i++) {
        cin >> v[i] >> w[i];
    }
    
    cout << __01_knapsack__(v, w, W) << endl;
    
    
    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

    int max = M / N;

    for (int i = max; i >= 1; i--)
    {
        if (M % i == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9 + 7;
typedef double Double;
struct Point {
    Double x,y;

    bool operator < (const Point &b)const{
        //return tie(x,y) < tie(b.x,b.y);
        //return atan2(y,x) < atan2(b.y,b.x);
        assert(0 && "choose compare");
    }
    Point operator + (const Point &b)const{
        return {x+b.x,y+b.y};
    }
    Point operator - (const Point &b)const{
        return {x-b.x,y-b.y};
    }
    Point operator * (const Double &d)const{
        return {d*x,d*y};
    }
    Point operator / (const Double &d)const{
        return {x/d,y/d};
    }
    Double operator * (const Point &b)const{
        return x*b.x + y*b.y;
    }
    Double operator % (const Point &b)const{
        return x*b.y - y*b.x;
    }
    friend Double abs2(const Point &p){
        return p.x*p.x + p.y*p.y;
    }
    friend Double abs(const Point &p){
        return sqrt( abs2(p) );
    }
};
typedef Point Vector;

struct Line{
    Point P; Vector v;
    bool operator < (const Line &b)const{
        return atan2(v.y,v.x) < atan2(b.v.y,b.v.x);
    }
};
Point circumcentre(Point &p0, Point &p1, Point &p2){
    Point a = p1-p0;
    Point b = p2-p0;
    Double c1 = abs2(a)*0.5;
    Double c2 = abs2(b)*0.5;
    Double d = a % b;
    Double x = p0.x + ( c1*b.y - c2*a.y ) / d;
    Double y = p0.y + ( c2*a.x - c1*b.x ) / d;
    return {x,y};
}
void SmallestCircle(int n, Point _p[]){
    Point *p = new Point[n];
    memcpy(p,_p,sizeof(Point)*n);
    random_shuffle(p,p+n);
    
    Double r2=0;
    Point cen;
    for (int i=0; i<n; i++){
        if ( abs2(cen-p[i]) <= r2)continue;
        cen = p[i], r2=0;
        for (int j=0; j<i; j++){
            if ( abs2(cen-p[j]) <= r2)continue;
            cen = (p[i]+p[j])*0.5;
            r2 = abs2(cen-p[i]);
            for (int k=0; k<j; k++){
                if ( abs2(cen-p[k]) <= r2)continue;
                cen = circumcentre(p[i],p[j],p[k]);
                r2 = abs2(cen-p[k]);
            }
        }
    }

    delete[] p;
    cout << fixed << setprecision(10) << sqrt(r2) << '\n';
    //return {cen,r2};
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k;
    cin >> n;
    Point P[n];
    f(n){
        cin >> P[i].x >> P[i].y;
    }
    SmallestCircle(n,P);
}

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

int main(void)
{
	char S[10];
	int num[10];
	int i, j, length = 0;
	long long int ans = 0;

	scanf("%s", S);
	while (S[++length] != '\0')
		;
	for (i = 0; i < length; i++) {
		num[i] = S[i] - '0';
	}

	for (i = 1; i <= length; i++) {
		ans += ((long long int)num[length - i] << (length - i)) * pow(10, i - 1);
		//printf("ans = %lld\n", ans);
		j = length - i - 1;
		while (j >= 0) {
			ans += ((long long int)num[j] << (length - i - 1)) * pow(10, i - 1);
			//printf("ans = %lld\n", ans);
			j--;
		}
	}
/*
 8 4 2 1 1  3 2 1 0 0
 8 4 2 2 0  3 2 1 1 
 8 4 4 0 0  3 2 2 
 8 8 0 0 0  3 3
16 0 0 0 0  4
*/
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 128
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        xs: [i128; n],
    }

    if xs.iter().any(|&x| x == 0) {
        println!("0");
        return;
    }

    let mut ans = 1i128;
    for x in xs {
        ans *= x;
        if ans > 1000000000000000000 {
            println!("-1");
            return;
        }
    }
    println!("{}", ans);
}


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

int main(){
 string w,t;
 int res=0;

 cin>>w;
 transform(w.begin(),w.end(),w.begin(),::toupper);
 while(true){
  cin>>t;
  if(t=="END_OF_TEXT") break;
  transform(t.begin(),t.end(),t.begin(),::toupper);
  if(t==w) res++;
 }
 cout<<res<<endl;
 return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int n; cin >> n;

	set <int> s;

	int a;

	for(int i = 0; i < n; i++){
		cin >> a;

		s.insert(a);
	}


	cout << (s.size() == n ? "YES" : "NO") << endl;
	
	
	
	return 0;
}

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

vector<bool> eratosthenes_sieve(int n){
	if(n<2)return vector<bool>();
	vector<bool> res(n+1);
	res[0]=res[1]=false;res[2]=true;
	int i,j;
	for(i=3;i<=n;i+=2){
		if(i*i<=n && res[i]==false){
			for(j=i+i+i;j<=n;j+=i+i){
				res[j]=true;
			}
		}
		res[i]=!res[i];
	}
	return res;
}

int a,d,n;
main(){
	int i,j;
	vector<bool> prime = eratosthenes_sieve(1000000);
	while(cin >> a >> d >> n, a){
		for(;n;a+=d){
			if(prime[a]) n--;
			if(!n) break;
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1344
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=2e5+5;
ll a[N],sum[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=n;i>=0;i--){
		sum[i]=sum[i+1]+a[i];
	}
	ll ans=0;
	ll num=1;
	for(int i=0;i<=n;i++){
		if(num<a[i]){
			printf("-1");
			return 0;
		}
		else{
			ans+=a[i];
			num-=a[i];
		}
		ll temp=num;
		for(int j=i+1;j<=n;j++){
			temp*=2;
			if(temp>=sum[i+1]){
				break;
			}
		}
		if(temp<sum[i+1]){
			printf("-1");
			return 0;
		}
		if(sum[i+1]>=num){
			ans+=num;
		}
		else{
			ans+=sum[i+1];
		}
		if(num<=1e15){
			num*=2;
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 5392
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let x: i32 = iter.next().unwrap().parse().unwrap();
    let y: i32 = iter.next().unwrap().parse().unwrap();
    let xs: Vec<i32> = (0..n).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let ys: Vec<i32> = (0..m).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let max_x = *xs.iter().max().unwrap();
    let min_y = *ys.iter().min().unwrap();

    let ans = std::cmp::max(max_x, x) < std::cmp::min(min_y, y);
    println!("{}", if ans { "No War" } else { "War" });

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=16;
int f[maxn+1][1<<maxn];
int edge[maxn+5][maxn+5];
int n,m;
int st[1<<maxn][maxn+5];
const int mod=1e9+7;
inline void add(int &x,int y){
	x=((x+y)>=mod?(x+y-mod):(x+y));
}
int main(){
	read(n);read(m);
	rep(i,1,m){
		int x,y;read(x);read(y);edge[x][y]=1;
	}
	rep(i,1,n)rep(j,0,(1<<n)-1){
		rep(k,0,n-1)if(j&(1<<k))
			st[j][i]+=edge[i][k+1];
	}
	rep(s,1,(1<<n)-1){
		if((1&s)&&(2&s))continue;
		int res=1;
		rep(i,1,n)if(!((1<<(i-1))&s)){
			res=1ll*res*((1<<st[s][i])-1)%mod;
		}
		rep(i,1,n)if((1<<(i-1))&s){
			res=1ll*res*(1<<(st[((1<<n)-1)^s][i]))%mod;
		}
		f[0][s]=res;
	}
	rep(i,1,n)rep(s,1,(1<<n)-1){
		//fprintf(stderr, "%d %d\n",i,s);
		for(int news=s&(s-1);news;news=(news-1)&(s))if(f[i-1][s^news]){
			if((1&news)&&(2&news))
				continue;
			int res=1;
			rep(i,1,n)if(!((1<<(i-1))&s)){
				res=1ll*res*((1<<st[news][i])-1)%mod;
			}else if((1<<(i-1))&news){
				res=1ll*res*(1<<(st[((1<<n)-1)^s][i]))%mod;
			}
			add(f[i][s],f[i-1][s^news]*1ll*res%mod);
		}
	}
	int ans=0;
	rep(i,0,n)add(ans,f[i][(1<<n)-1]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8576
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  deque<ll> q;
  cin >> n;

  rep(i,n)
  {
    ll buf;
    cin >> buf;

    if(i%2)
    {
      q.push_front(buf);
    }
    else
    {
      q.push_back(buf);
    }
  }

  vector<ll> b(n);

  rep(i,n)
  {
    b[i] = q.front();
    q.pop_front();
  }

  if(n % 2 != 0)
  {
    reverse(all(b));
  }

  rep(i,n)
  {
    if(i == 0)
      cout << b[i];
    else
    {
      cout << " " << b[i];
    }
  }

  cout << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 5376
// finish date: 2018/04/28

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    vl ruiseki(N, 0);
    map<ll, int> mp;
    rep(i, N) {
        ruiseki[i] = A[i];
        if (i > 0) ruiseki[i] += ruiseki[i - 1];
        mp[ruiseki[i]]++;
    }
    ll ans = 0;
    for (auto entry:mp) {
        ans += (ll) entry.second * (entry.second - 1) / 2;
    }
    ans += mp[0];
    printf("%.0f\n", ans);
    //cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872
from collections import deque

n = int(input())
A = list(map(int, input().split()))

B = [0] * n
B[0] = A[0]
B[1] = A[1]
for i in range(2, n):
    B[i] = B[i - 2] + A[i]

ANS = [0] * n
for i in range(n):
    ans = 0
    if i % 2 == 0:
        ans += B[-1] - B[-2]
    else:
        ans += B[-2] - B[-1]

    if i - 2 >= 0:
        ans -= B[i - 2] * 2

    if i - 1 >= 0:
        ans += B[i - 1] * 2

    ANS[i] = ans

print(*ANS)


Measured memory_bytes: 18728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define spc printf(" ")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
 
///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///#define triangle_area(a,b,m,n,x,y) (a*(n-y)+m*(y-b)+x*(b-n))/2.0
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=500006;
int main()
{
    //#ifndef ONLINE_JUDGE
   	//FI;
    //FO;
    //#endif
    //ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    while(cin>>s)
    {
    	int cnt=0;
    	for(int i=0,j=s.size()-1;i<=j;i++,j--)
    	{
    		if(s[i]!=s[j])cnt++;
    	}
    	pf("%d\n",cnt);
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto N = to!ulong(tokens[0]);
	auto W = to!ulong(tokens[1]);

	long[] w, v;
	foreach (i; 0..N)
	{
		auto tokens2 = split(my_readln());
		{
			w ~= to!long(tokens2[0]);
			v ~= to!long(tokens2[1]);
		}
	}

	long[][] dp;
	dp.length = 100100;
	foreach (ref e; dp) e.length = 110;

	foreach (i; 0..N)
	{
		foreach (j; 0..W+1)
		{
			if (j >= w[i]) dp[j][i+1] = max(dp[j-w[i]][i] + v[i], dp[j][i]);
			else dp[j][i+1] = dp[j][i];
		}
	}

	writeln(dp[W][N]);
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}

Measured memory_bytes: 108156
#include<iostream>
    #include<iomanip>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    #define maxn 200010
    using namespace std;
    struct edge{
        int l,r;
    }c[maxn];
    bool cmp(edge a,edge b)
    {
        if(a.l==b.l) return a.r>b.r;
        return a.l<b.l;
    }
    struct tree{
        int l,r,mi;
        tree *ls,*rs;
        tree()
        {
            ls=rs=NULL;
            l=r=0;
            mi=0x3f3f3f3f;
        }
        void update()
        {
            mi=min(ls->mi,rs->mi);
        }
        void build(int lx,int rx)
        {
            l=lx;r=rx;
            if(l==r) {
                mi=(l==0?0:0x3f3f3f3f);
                return;
            }
            int mid=(l+r)>>1;
            (ls=new tree)->build(lx,mid);
            (rs=new tree)->build(mid+1,rx);
            update();
        }
        void modify(int pos,int num)
        {
            if(l==r) {
                mi=min(mi,num);
                return;
            }
            int mid=(l+r)>>1;
            if(pos<=mid) ls->modify(pos,num);
            else rs->modify(pos,num);
            update();
        }
        int query(int lx,int rx)
        {
            if(l==lx&&r==rx) return mi;
            int mid=(l+r)>>1;
            if(lx>mid) return rs->query(lx,rx);
            else if(rx<=mid) return ls->query(lx,rx);
            else return min(ls->query(lx,mid),rs->query(mid+1,rx));
        }
    }*xtr;
    int n,q,b[maxn];
    int main()
    {
        scanf("%d",&n);
        int ans=0;
        for(int i=1;i<=n;++i) scanf("%d",&b[i]),ans+=(1-b[i]);
        scanf("%d",&q);
        for(int i=1;i<=q;++i)
        scanf("%d%d",&c[i].l,&c[i].r);
        sort(c+1,c+q+1,cmp);
        (xtr=new tree)->build(0,n);
        int p=1;
        for(int i=1;i<=n;++i)
        {
            for(;c[p].l==i;++p)
            xtr->modify(c[p].r,xtr->query(i-1,c[p].r));
            xtr->modify(i,xtr->query(i-1,i-1)+(b[i]==0?-1:1));
        }
    cout<<ans+xtr->query(n,n);
    return 0;
    }

Measured memory_bytes: 23424
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    if(b-a<2*k)
    {
        for(int i=a; i<=b; i++)
            cout<<i<<endl;
        return 0;
    }
    for(int i=a; i<a+k; i++)
        cout<<i<<endl;
    for(int i=b-k+1; i<=b; i++)
        cout<<i<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    int MAX_M = 100000;
    int MAX_N = 100000;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        dp = new long[N];
        for (int i = 0; i < N; i++) {
            dp[i] = sc.nextInt();
        }
        long x = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 1) {
                x -= dp[i];
            } else {
                x += dp[i];
            }
        }
        long[] ans = new long[N];
        ans[0] = x / 2;
        for (int i = 0; i < N-1; i++) {
            ans[i+1]  = dp[i] - ans[i];
        }
        
        for(int i = 0;i < N;i++){
            System.out.print(ans[i]*2+" ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 66404
#include<stdio.h>
#define INF 1000000005

int cnt;

int merge(int A[],int l,int m,int r){
  int R[250010],L[250010];
  int i,j,k;
  int n1,n2;
  n1 = m - l;
  n2 = r - m;

  for(i=0;i<n1;i++){
    L[i] = A[l+i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[m+i];
  }
  L[n1] = INF;
  R[n2] = INF;
  i = 0;
  j = 0;

  for(k=l;k<r;k++){
    cnt++;
    if(L[i] <= R[j]){
       A[k] = L[i];
       i += 1;
    }else{
      A[k] = R[j];
      j += 1;
    }
  }
}

void  mergesort(int A[],int l,int r){
  int m;
  if(l + 1 < r){
    m = (l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}


int main(){
  int n;
  int S[500005];
  int i;
  cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
    mergesort(S,0,i);

    for(i=0;i<n;i++){
        printf("%d",S[i]);
      if(i<n-1){
        printf(" ");
      }
    }
    puts("");
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 5704
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    char ch[300],ptn[11],end[]="END_OF_TEXT";
    int i,x=0;
    
    scanf("%s",ptn);
    for (i=0; i< strlen(ptn); i++) {
        ptn[i] = tolower(ptn[i]);
    }
    while(1){
        scanf("%s",ch);
        if(strcmp(ch,end)==0) break;
        for (i=0; i< strlen(ptn); i++) {
            if (isupper(ch[i])) {
                ch[i]=tolower(ch[i]);
            }
        }
    if (strcmp(ch, ptn)==0) {
        x++;
    }
    }
    printf("%d\n",x);
    return(0);
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define vi vector < ll  int >
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007
        #define pc __builtin_popcount
using namespace std;
/*
vector < int > tree(400005);

void buildtree (vector < int > v,int node,int start,int fin)
  {
      if(start==fin)
      {
          tree[node]=v[start];
          return;
      }
      int mid=(start+fin)/2;
      buildtree(v,2*node,start,mid);
      buildtree(v,2*node+1,mid+1,fin);
      tree[node]=tree[2*node]+tree[2*node+1];
  }

 int sum (int node,int tl,int tr,int l , int r)
   {
       if(l>r) return 0;
       if(l==tl and r==tr) return tree[node];
       int mid=(tl+tr)/2;
       return sum(2*node,tl,mid,l,min(r,mid))+sum(2*node+1,mid+1,tr,max(l,mid+1),r);
   }

  void update(int node,int tl , int tr,int pos,int val)
    {
        if(tl==tr) {tree[node]=val; return;}
        int mid=(tl+tr)/2;
        if(pos<=mid)
              update(2*node,tl,mid,pos,val);
        else
            update(2*node+1,mid+1,tr,pos,val);
        tree[node]=tree[2*node]+tree[2*node+1];

    } */


void solve()
{
ll i,j=0,r=200,p,q,k=1,ans=0,d,y=0,x,n,h,flag=0,m=0,id,c,h1,h2,a1,b1,w,a,b;
cin>>m>>d;
rep(i,10,d+1)
  {    k=(i/10); x=(i%10);
      if(k>=2 and x>=2 and k*x<=m) y++;
  }
  cout<<y;

}


    signed main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
            //cin>>t;
            while(t--)
            solve();
        }


Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	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 getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	for s, c := getNextString(scanner), getNextString(scanner); c != "X"; s, c = getNextString(scanner), getNextString(scanner) {
		if strings.Index(s, "_") != -1 {
			fmt.Fprintln(writer, translate(strings.Split(s, "_"), c))
			continue
		}
		ss := make([]string, 0)
		for len(s) > 0 {
			index := nextupper(s[1:])
			ss = append(ss, s[:index+1])
			s = s[index+1:]
		}
		fmt.Fprintln(writer, translate(ss, c))
	}
}
func translate(ss []string, c string) string {
	switch c {
	case "U":
		return u(ss)
	case "L":
		return l(ss)
	case "D":
		return d(ss)
	}
	return ""
}

func nextupper(s string) int {
	n := len(s)
	for i := 0; i < n; i++ {
		if s[i:i+1] == strings.ToUpper(s[i:i+1]) {
			return i
		}
	}
	return n
}
func u(ss []string) string {
	n := len(ss)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%s%s", strings.ToUpper(ss[i][0:1]), ss[i][1:])
	}
	return strings.Join(ss, "")
}
func l(ss []string) string {
	n := len(ss)
	ss[0] = strings.ToLower(ss[0])
	for i := 1; i < n; i++ {
		ss[i] = fmt.Sprintf("%s%s", strings.ToUpper(ss[i][0:1]), ss[i][1:])
	}
	return strings.Join(ss, "")
}
func d(ss []string) string {
	n := len(ss)
	for i := 0; i < n; i++ {
		ss[i] = strings.ToLower(ss[i])
	}
	return strings.Join(ss, "_")
}



Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  
  int K, X; std::cin >> K >> X;

  for(int i=0; i<2*K-1; i++) {
    std::cout << X-K+1+i << " ";
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if(a==b && b==c)
		printf("1\n");
	else if(a==b || b==c || c==a)
		printf("2\n");
	else
		printf("3\n");


	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict as dd

n = int(raw_input().strip())
ais = map(int, raw_input().strip().split())

coll = dd(int)
for ai in ais:
    coll[ai] += 1

total = 0
for key, value in coll.iteritems():
    if value < key:
        total += value
    else:
        total += value - key

print total


Measured memory_bytes: 16288
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  int64_t K;
  cin>>S>>K;
  int64_t N=S.size();
  int64_t Min=min(N-1,K-1);
  char c='1';
  for(int64_t i=0;i<=Min;i++){
  if(S.at(i)!='1'){
   c=S.at(i); break;
  }
  
  }cout<<c<<endl;
 
return 0;
}



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

#define int long long

main()
{
  int n, x;
  int d;
  
  cin >> n >> x;

  d = __gcd(n, x);
  n /= d;

  cout << d * 3 * (n - 1) << endl;
  
  return (0);
  
}


Measured memory_bytes: 256
import numpy as np

N, M, C = map(int, input().split())
B = list(int(b) for b in input().split())
A = []
for i in range(N):
    a = list(int(a) for a in input().split())
    A.append(a)

flag = 0
for n in range(N):
    sum_calc = 0
    for m in range(M):
        calc = A[n][m] * B[m]
        sum_calc+=calc
    result = sum_calc + C
    if result>0:
        flag+=1
print(flag)

Measured memory_bytes: 12444
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;
typedef unsigned int uint;

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

    vector<int> H(N);

    int ret = 0;
    rep(i,N){
        cin >> H.at(i);

        bool isView = true;
        for(int j = 0; j < i; j++) {
            if (H.at(j) > H.at(i)) {
                isView = false;
                break;
            }
        }
        if (isView) ret ++ ;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
# findの中で同じグループに属する頂点のアップデートも行なっている
def find(i)
  if i == $con[i]
    return i
  else
    nxt = find($con[i])
    $con[i] = nxt
    return nxt
  end
end

def union(i, j)
  x = find(i)
  y = find(j)
  if x == y
    return nil
  else
    $con[x] = y
    return nil
  end
end

def main()
  n,m = gets.chomp.split(' ').map(&:to_i)
  target = gets.chomp.split(' ').map(&:to_i).map{|x| x - 1}
  ans = 0
  $con = (0..n-1).to_a

  for num in 0..m-1 do
    x,y = gets.chomp.split(' ').map(&:to_i)
    union(x-1,y-1)
  end
  #solve
  n.times{ |i|
    ans = ans + 1 if find(i) == find(target[i])
  }
  puts ans
end

main()

Measured memory_bytes: 12804
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    string S;
    cin >> S;
    bool flag;
    int tmp = S.find('C');
    if ((2 <= tmp) && (tmp<=(S.size()-2)))
    {
        if (S[0] == 'A')
        {
            flag = true;
            for (int i = 1; i < S.size(); i++)
            {
                if (i != tmp)
                {
                    if ((S[i] < 'a') || (S[i] > 'z'))
                    {
                        flag = false;
                        break;
                    }
                }
            }
        }
    }
    else
    {
        flag = false;
    }
    if (flag)
    {
        cout << "AC" << endl;
    }
    else
    {
        cout << "WA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256