akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T>
class SegmentTree{
    public:
        ll size;
        vector<T> node;
        T identity_ele;  //comp(x, identity_ele) == x
        function<T(T, T)> comp;

        SegmentTree(const vector<T> &v, function<T(T, T)> comp, T identity_ele){
            ll tmp = 1;
            while(tmp < v.size()) tmp = (tmp << 1);
            this->size = tmp;
            this->identity_ele = identity_ele;
            this->comp = comp;
            node.resize(2 * size - 1);
            for(ll i = 0; i < v.size(); i++){
                node[i + size - 1] = v[i];
            }
            for(ll i = size - 2; 0 <= i; i--){
                node[i] = comp(node[i * 2 + 1], node[i * 2 + 2]);
            }
        }

        void update(ll pos){
            pos += size - 1;
            node[pos]++;
            while(pos > 0){
                pos = (pos - 1) / 2;
                node[pos]++;
            }
        }

        T query(ll a, ll b){
            return subQuery(a, b, 0, 0, size);
        }

        T subQuery(ll a, ll b, ll k, ll l, ll r){
            return (r <= a || b <= l ? identity_ele : (a <= l && r <= b ? node[k] : comp(subQuery(a, b, k * 2 + 1, l, (l + r) / 2), subQuery(a, b, k * 2 + 2, (l + r) / 2, r))));
        }
};

void setID(map<ll, ll> &ma, ll v){
    if(ma.find(v) != ma.end()) return;
    ll num = ma.size();
    ma[v] = num;
}

map<ll, ll> sortedID(vector<ll> v){
    sort(v.begin(), v.end());
    map<ll, ll> ret;
    for(auto u : v) setID(ret, u);
    return ret;
}

int main(){
    ll N;
    cin >> N;
    ll x[N];
    for(ll i = 0; i < N; i++) cin >> x[i];
    vector<ll> kind(N);
    copy(x, x + N, kind.begin());
    sort(kind.begin(), kind.end());
    auto tmp = unique(kind.begin(), kind.end());
    kind.erase(tmp, kind.end());
    ll ng = kind.size(), ok = 0;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        ll tmp[N];
        for(ll i = 0; i < N; i++) tmp[i] = (kind[mid] <= x[i] ? 1 : -1);
        vector<ll> sum(N + 1);
        for(ll i = 0; i < N; i++) sum[i + 1] = sum[i] + tmp[i];
        map<ll, ll> ID = sortedID(sum);
        SegmentTree<ll> S(vector<ll>(ID.size(), 0), [](ll a, ll b){return a + b;}, 0);
        S.update(ID[0]);
        ll po = 0;
        sum.erase(sum.begin());
        for(auto u : sum){
            po += S.query(0, ID[u] + 1);
            S.update(ID[u]);
        }
        ll yo = N * (N - 1) / 2 + N;
        if(po >= yo / 2) ok = mid;
        else ng = mid;
    }
    cout << kind[ok] << endl;
    return 0;
}


Measured memory_bytes: 10844
n,m = map(int,input().split())
a = list(map(int,input().split()))

a.sort()
bc = [list(map(int,input().split())) for _ in range(m)]
bc.sort(key=lambda x:x[1],reverse=True)
l = []
for i in bc:
    l.extend([i[1]] * i[0])
    if len(l) > len(a):
        break

for i in range(min(len(a),len(l))):
    a[i] = max(a[i],l[i])
print(sum(a))

Measured memory_bytes: 87788
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>> a >> b;
    int n=a.size();
    
    int count=0;
    
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]) count++;
    }
    
    cout << count <<endl;
}

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

int z(int x){
	if(x<0)return -x;
	return x;
}

int main(){
	int MINF=-100000000;
	int d,n,t[202],a[202],b[202],c[202],dp[202][202];
	for(int i=0;i<202;i++)for(int j=0;j<202;j++)dp[i][j]=MINF;
	scanf("%d%d",&d,&n);
	for(int i=1;i<=d;i++){
		scanf("%d",&t[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for(int i=1;i<=n;i++)if(a[i]<=t[1]&&t[1]<=b[i])dp[1][i]=0;
	for(int i=2;i<=d;i++){
		for(int j=1;j<=n;j++){
			if(a[j]<=t[i]&&t[i]<=b[j]){
				for(int k=1;k<=n;k++){
					if(dp[i][j]<dp[i-1][k]+z(c[k]-c[j]))dp[i][j]=dp[i-1][k]+z(c[k]-c[j]);
				}
			}
		}
	}
	/*for(int i=1;i<=d;i++){
		cout<<i<<":"<<endl;
		for(int j=1;j<=n;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int ans=MINF;
	for(int i=1;i<=n;i++){
		if(ans<dp[d][i])ans=dp[d][i];
	}
	printf("%d\n",ans);
}

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

int main() {
  ll ans = 0;
  int n;
  cin >> n;
  vector<ll> A(n+1),B(n);
  rep(i,n+1){ cin >> A[i]; }
  rep(i,n){ cin >> B[i]; }

  rep(i,n){
    int a = min(A[i],B[i]);
    A[i] -= a;
    B[i] -= a;
    ans += a;
    if (B[i] > 0){ 
      a = min(A[i+1],B[i]);
      A[i+1] -= a; 
      ans += a;
    }
  }

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


Measured memory_bytes: 1792
array = list(map(int, input().split()))

if (array[0] == array[1]) & (array[1] == array[2]) & (array[2] == array[0]):
    print('No')

elif (array[0] != array[1]) & (array[1] != array[2]) & (array[2] != array[0]):
    print('No')

else:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  int n[4];
  map<int, int> mp;
  REP(i, 4){
    cin >> n[i];
    mp[n[i]]++;
  }

  if(mp[1] && mp[9] && mp[7] && mp[4]){
    cout << "YES" << endl;
    return 0;
  }
    
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
int main(){
	long long a, n, i, s=0,mi=1000000000000001;
	int k=0;
	scanf("%lld", &n);
	for(i=0;i<5;i++){
		scanf("%lld", &a);
		if(mi>a){
		mi=a;
		k=4;
		}	
	}
	if(n<=mi){
		printf("5");
		return 0;
	}
	if(n%mi==0)
	printf("%lld", n/mi+k);
	else
	printf("%lld", n/mi+1+k);
	
	return 0;
	
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int n;
bool b[105][105];
bool c[105];

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				b[i][j] = false;
			}
		}
		int m, p;
		for(int i = 1; i <= n; i++){
			cin >> m;
			for(int j = 0; j < m; j++){
				cin >> p;
				b[i][p] = true;
			}
		}
		int k;
		cin >> k;
		for(int i = 1; i <= n; i++) c[i] = false;
		for(int i = 1; i <= k; i++){
			cin >> p;
			c[p] = true;
		}
		
		int ans = 0, ans_i;
		for(int i = 1; i <= n; i++){
			bool flag = true;
			for(int j = 1; j <= n; j++){
				if(c[j] && !b[i][j]) flag = false;
			}
			if(flag) ans++, ans_i = i;
		}
		if(ans == 1) cout << ans_i << endl;
		else cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;

template <int M, bool IsPrime = false> class Modulo {
  int n;
  static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
  }

public:
  Modulo() : n(0) { ; }
  Modulo(int m) : n(m) {
    if (n >= M)
      n %= M;
    else if (n < 0)
      n = (n % M + M) % M;
  }
  Modulo(ll m) {
    if (m >= M)
      m %= M;
    else if (m < 0)
      m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo &operator+=(const Modulo &a) {
    n += a.n;
    if (n >= M) n -= M;
    return *this;
  }
  Modulo &operator-=(const Modulo &a) {
    n -= a.n;
    if (n < 0) n += M;
    return *this;
  }
  Modulo &operator*=(const Modulo &a) {
    n = (ll(n) * a.n) % M;
    return *this;
  }
  Modulo operator+(const Modulo &a) const {
    Modulo res = *this;
    return res += a;
  }
  Modulo operator-(const Modulo &a) const {
    Modulo res = *this;
    return res -= a;
  }
  Modulo operator-() const { return Modulo(0) - *this; }
  Modulo operator*(const Modulo &a) const {
    Modulo res = *this;
    return res *= a;
  }

  Modulo operator^(ll m) const {
    if (m == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (m / 2);
    return m % 2 ? res * a : res;
  }
  typename std::enable_if<IsPrime, Modulo>::type
  operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
  typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
    return *this *= inv(ll(a), M);
  }

  friend bool is_zero(const Modulo &x) { return int(x) == 0; }
  friend int abs(const Modulo &x) { return int(x); }

  static Modulo fact(int n, bool sw = true) {
    static std::vector<Modulo> v1 = { 1 }, v2 = { 1 };
    if (n >= (int)v1.size()) {
      const int from = v1.size(), to = n + 1024;
      v1.reserve(to);
      v2.reserve(to);
      for (int i = from; i < to; ++i) {
        v1.push_back(v1.back() * Modulo<M, true>(i));
        v2.push_back(v2.back() / Modulo<M, true>(i));
      }
    }
    return sw ? v1[n] : v2[n];
  }
  static Modulo comb(int a, int b) {
    if (b < 0 || b > a) return 0;
    return Modulo::fact(a, true) * Modulo::fact(b, false) *
           Modulo::fact(a - b, false);
  }
};
using Mod = Modulo<1000000007, true>;

int main(void)
{
  int x, y;
  cin >> x >> y;
  if((x+y)%3) {
    cout << 0 << endl;
  } else {
    int n = (x+y)/3;
    cout << (ll)Mod::comb(n, x-n) << endl;
  }
  return 0;
}



Measured memory_bytes: 5768
#include<bits/stdc++.h>
using namespace std;
const int N=250000;
int ll[N],rr[N],ans,check[30];
string s;
int main()
{
    cin>>s;
    int len=s.length(),now=26;
    rr[0]=len-1;
    for(int i=len-1;i>=0;i--)if(!check[s[i]-'a'])
    {
        now--;
        check[s[i]-'a']=1;
        if(now==0)
        {
            ll[ans]=i;ans++;rr[ans]=i-1;now=26;
            memset(check,0,sizeof(check));
        }
    }
    ll[ans]=0;
    int last=0;
    char ans_now;
    for(int i=ans;i>=0;i--)
    {
        int now=26;
        memset(check,0,sizeof(check));
        for(int j=last;j<=rr[i];j++)check[s[j]-'a']=1;
        for(int j=0;j<26;j++)if(!check[j])
        {
            printf("%c",j+'a');
            ans_now=j+'a';
            break;
        }
        for(int j=last;j<len;j++)
        if(s[j]==ans_now){last=j+1;break;}
    }
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////

int n,q;string s;
set<int> st[30];vector<int> ans;
signed main(){
  cin>>n>>s>>q;
  rep(i,n){
    int ss = (int)(s[i]-'a');
    st[ss].insert(i);
  }

  rep(_,q){
    int b;cin>>b;
    if(b == 1){
      int i;char cc;cin>>i>>cc;
      i--;
      int c = (int)(cc-'a');
      int k = (int)(s[i]-'a');
      s[i] = cc;
      st[k].erase(i);
      st[c].insert(i);
    }else{
      int l, r;cin>>l>>r;
      l--;r--;
      int ret = 0;
      rep(i,26){
        auto itr = st[i].lower_bound(l);
        if(itr == st[i].end())continue;
        int x = *itr;
        if(x <= r)ret++;
      }
      ans.push_back(ret);
    }
  }
  rep(i,ans.size())cout << ans[i] << endl;
}




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

int main() {
  int n; cin >> n;
  int ans = -1;
  rep(i,n+1) {
    if (n == i * 108/100) {
      ans = i;
      break;
    }
  }
  if (ans == -1) {
    cout << ":(" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	char curr = 'a';
	int cnt = 0;
	for(int i = 0; i < s.length(); i++){
		if(curr != s.at(i)){
			cnt++;
			curr = s.at(i);
		}
	}
	cout << cnt - 1 << endl;
	return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return n != 1;
}

int main() {
  ll sum[10001];
  sum[0] = 0;
  int cnt = 1, val = 1;
  while (cnt <= 10000) {
    while (!is_prime(val)) val++;
    sum[cnt] = sum[cnt - 1] + val;
    cnt++, val++;
  }
  int n;
  while (cin >> n && n) {
    cout << sum[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B, M; std::cin >> A >> B >> M;
  std::vector<int> a(A), b(B);
  rep(i, A) std::cin >> a[i];
  rep(i, B) std::cin >> b[i];

  int amin = *std::min_element( all(a) );
  int bmin = *std::min_element( all(a) );

  int ans = amin +  bmin;
  rep(i, M) {
    int x, y, c;
    std::cin >> x >> y >> c;
    x--, y--;
    ans = std::min(ans, a[x]+b[y]-c);
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#define M 16384
#define p 998244353
#define ll long long
inline int mod(int x){return x<p?x:x-p;}
inline int calc(int x,int y)
{
    int z=1;
    for(;y;x=(ll)x*x%p,y>>=1)if(y&1)z=(ll)x*z%p;
    return z;
}
int i,j,k,f[M],o,q,w[M|1],x,y,z;
inline void swap(int&u,int&v){z=u,u=v,v=z;}
inline void NTT(int*a,int s)
{
    for(i=0;i<q;i++)if(f[i]>i)swap(a[f[i]],a[i]);
    for(i=1;i<q;i<<=1)for(j=0,k=i,s>>=1;k<q;j+=i,k+=i)for(z=q&s;k&i;z+=s)x=a[j],y=(ll)a[k]*w[z]%p,a[j++]=mod(x+y),a[k++]=mod(p+x-y);
    if(s<0)for(i=0;i<q;i++)a[i]=(ll)a[i]*o%p;
}
int a[M],b[M],c[M],d[M],e[M],m,n;
int main()
{
    for(scanf("%d%d",&n,&m),q=1;q<=n<<1;q<<=1)o++;
    for(z=calc(3,p>>o--),i=*w=w[q]=1;i<q;i++)f[i]=f[i>>1]>>1|(i&1)<<o,w[i]=(ll)w[i-1]*z%p;
    for(*a=a[1]=*b=b[1]=1,i=2;i<=n+2;i++)a[i]=(ll)a[i-1]*i%p,b[i]=(ll)(p-p/i)*b[p%i]%p;
    for(i=2,o=calc(q,p-2);i<=n+2;i++)b[i]=(ll)b[i-1]*b[i]%p;
    for(i=0;i<=n;i++)c[i]=b[i+2];
    for(NTT(c,q),*d=1;m;m--)
    {
        for(i=0;i<=n;i++)e[i]=(ll)d[i]*b[i]%p,d[i]=(ll)d[i]*(p-i)%p;
        for(NTT(e,q),i=0;i<q;i++)e[i]=(ll)c[i]*e[i]%p;
        for(NTT(e,-q),i=0;i<=n;i++)d[i]=(d[i]+(ll)e[i]*a[i+2])%p,e[n+i+1]=0;
    }
    for(i=x=0;i<=n;i++)x=(x+(ll)b[i]*b[n-i]%p*a[n]%p*d[i])%p;
    return 0&printf("%d\n",x);
}

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

int main() {
    ll N, WM; cin >> N >> WM;
    map<ll, ll> DP; // key: weight, value: value :-)

    pair<ll, ll> *D = new pair<ll,ll>[N];
    rep(i,N) {
        ll w, v; cin >> w >> v;
        D[i].first  = w;
        D[i].second = v;
    }

    DP[0] = 0;
    for (int i = 0; i < N; i++) {
        for (auto j = DP.rbegin(); j != DP.rend(); j++) {
            ll w = D[i].first + j->first;
            ll v = D[i].second + j->second;
            if (w <= WM) {
                DP[w] = max(DP[w], v);
            }
        }
    }
    ll ma = 0;
    for (auto j = DP.begin(); j != DP.end(); j++) {
        ma = max(ma, j->second);
    }
    cout << ma << endl;
}


Measured memory_bytes: 384
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	s := stdin.Read()
	if ok, _ := regexp.MatchString("^(hi)+$", s); ok {
		stdout.Println("Yes")
	} else {
		stdout.Println("No")
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<bitset>
using namespace std;
int n;
string s;
char c[]={'M','A','R','C','H'};
long long int a[5],ans;
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<5;j++){
      if(s[0]==c[j])a[j]++;
    }
  }
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
	ans+=(a[i]*a[j]*a[k]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    count = 0
    for i in range(1, N+1, 2):
        yakusu_count = 0
        for j in range(1, i+1):
            if i % j == 0:
                yakusu_count += 1
        if yakusu_count == 8 :
            count += 1
    print count


if __name__ == '__main__':
    main()

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



int main(){
	int H, A;
	cin >> H >> A;
	int ans = H / A;
	if(H%A !=0) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[] a = new int[] {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();

        System.out.println(a[K-1]);
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,n,a[200001],b[200001],w,x;
	long long cnt;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(i=0;i<=n;i++)	b[i]=0;
	w=n-a[n];
	if(w<=n && w>=0)	b[w]++;
	cnt=0;
	for(i=n-1;i>=1;i--)	{
		w=i+a[i];
//		printf("w=%d\n",w);
		if(w>=0 && w<=n)	cnt+=b[w];
		x=i-a[i];
		if(x<=n && x>=0)	b[x]++;
	}
	printf("%lld\n",cnt);
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  
  string S;
  cin >> S;
  
  S.at(K-1) = S.at(K-1) + 32;
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 100005
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
inline int getint(){
  char c; int res = 0;
  for(c = getchar();c < '0' || c > '9';c = getchar());
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res;
}
P p[maxn];//cst, num.
int n,m;

int main(){
  n = getint(), m = getint();
  for(int i = 1;i <= n;i++){
    p[i].first = getint(), p[i].second = getint();
  }
  sort(p + 1,p + n + 1);
  ll res = 0;
  for(int i = 1;i <= n;i++){
    if(m <= p[i].second){
      res += m * p[i].first;
      break;
    }
    res += p[i].second * p[i].first;
    m -= p[i].second;
  }
  printf("%lld\n",res);
  return 0;
}


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

int main()
{
    int n,i,a,b,d;
    cin >> n;
    a = (n/2)-1;
    b = a+1;
    int N[n];
    for(i=0;i<n;i++)
    {
        cin >> N[i];
    }
    sort(N,N+n);
    d = N[b]-N[a];
    cout << d << endl;
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

P p[300000];
ll dp[300000][50];

int main(){
	int n;ll T;cin>>n>>T;T++;
	vector<P>u,v;
	rep(i,n){
		scanf("%lld%lld",&p[i].first,&p[i].second);p[i].second++;
		if(p[i].first){
			u.push_back(p[i]);
		}
		else v.push_back(p[i]);
	}
	sort(u.begin(),u.end(),[](P a,P b){
		return a.second*(ll)b.first<b.second*(ll)a.first;
	});
	sort(v.begin(),v.end(),[](P a,P b){
		return a.second<b.second;
	});
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=1;
	rep(i,u.size())rep(j,50){
		if(dp[i][j]==INFL)continue;
		dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		if(INFL/u[i].first<dp[i][j])continue;
		ll len=u[i].first*dp[i][j]+u[i].second;
		dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+len);
	}
	ll sum=0;
	int Max=0;
	for(int i=0;i<=v.size();i++){
		rep(j,50){
			ll F=dp[u.size()][j]+sum;
			if(F<=T)Max=max(Max,j+i);
		}
		if(i<v.size())sum+=v[i].second;
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 125164
#include <stdio.h>

int
main(int argc,char *argv[])
{
  int N, T, c[100], t[100];
  scanf("%d%d", &N, &T);
  for(int i = 0; i < N; i++)
  {
    scanf("%d%d", &c[i], &t[i]);
  }
  
  int min_cost = 1001;
  
  for(int i = 0; i < N; i++){
    if(t[i] <= T && min_cost > c[i]){
      min_cost = c[i];
    }
  }
  
  if(min_cost == 1001){
    printf("%s\n", "TLE");
  }
  else{
    printf("%d\n", min_cost);
  }
  
  return 0;
}
    


Measured memory_bytes: 128
unittest
{
	assert( [ "5", "1 1 2 1 2" ].parse.expand.solve == "2\n2\n3\n2\n3" );
	assert( [ "4", "1 2 3 4" ].parse.expand.solve == "0\n0\n0\n0" );
	assert( [ "5", "3 3 3 3 3" ].parse.expand.solve == "6\n6\n6\n6\n6" );
	assert( [ "8", "1 2 1 4 2 1 4 1" ].parse.expand.solve == "5\n7\n5\n7\n7\n5\n7\n5" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	long[ long ] ns;
	foreach( a; as )
	{
		ns[ a ]++;
	}
	
	long[ long ] ps;
	auto pt = 0L;
	foreach( a, n; ns )
	{
		ps[ a ] = n * ( n - 1 ) / 2;
		pt += n * ( n - 1 ) / 2;
	}
	
	auto anss = new long[ as.length ];
	foreach( ref ans, a; lockstep( anss, as ) )
	{
		auto p = ( ns[ a ] - 1 ) * ( ns[ a ] - 2 ) / 2;
		ans = pt - ps[ a ] + p;
	}
	return anss.to!( string[] ).join( "\n" );
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long

#define mod  1000000007


int main()
{
	FAST;
	ll n;
	cin >> n;
	if(n % 2 || n < 10){
		cout << 0;
		return 0;
	}
	ll ans = n/10;
	n /= 10;
	while(n ){
		n /= 5;
		ans += n;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <ctype.h>

int parse(char *a);

int main(void) {
	int i, j, count;
	char numA[9], numB[9], ans[9];

	scanf("%d", &count);
	for (i = 0; i < count; i++) {
		for (j = 0; j<9; j++) {
			numA[j] = 0;
			numB[j] = 0;
			ans[j] = 0;
		}

		scanf("%s %s ", numA, numB);
		output(parse(numA) + parse(numB));
	}
	return 0;
}

int parse(char *a) {
	int ans = 0;
	int i = 1;

	for (; *a; a++) {
		if (isdigit(*a)) {
			i = *a - '0';
			continue;
		}
		switch (*a) {
			case 'm':ans = ans + i * 1000; break;
			case 'c':ans = ans + i * 100; break;
			case 'x':ans = ans + i * 10; break;
			case 'i':ans = ans + i; break;
		}
		i = 1;
	}
	return ans;
}

int output(int ans) {
	int x;

	x = ans / 1000;
	if (x != 0) {
		if (x > 1) {
			printf("%d", x);
		}
		printf("m");
	}

	x = (ans / 100) % 10;
	if (x != 0) {
		if (x > 1) {
			printf("%d", x);
		}
		printf("c");
	}

	x = (ans / 10) % 10;
	if (x != 0) {
		if (x > 1) {
			printf("%d", x);
		}
		printf("x");
	}

	x = ans % 10;
	if (x != 0) {
		if (x > 1) {
			printf("%d", x);
		}
		printf("i");
	}
	printf("\n");
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

vector<ll> sieve(ll n){
  vector<bool> is_prime(n+1,true);
  vector<ll> res;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      res.push_back(i);
      for(int j=2*i;j<=n;j+=i){
        is_prime[j] = false;
      }
    }
  }
  return res;
}

vector<ll> divisor(ll n){
  vector<ll> list;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      list.push_back(i);
      if(n/i != i){
        list.push_back(n/i);
      }
    }
  }
  return list;
}

umap<int,int> prime_factor(ll n){
  umap<int,int> fac;
  for(int i=2;i*i<=n;i+=2){
    if(n%i == 0){
      int count = 0;
      while(n%i == 0){
        count++;
        n /= i;
      }
      fac[i] = count;
    }
  }
  if(n!=1)fac[n] = 1;
  return fac;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  
  int n,m;
  cin >> n >> m;
  
  vector<ll> fac = divisor(m);
  
  int max = 0;
  
  for(auto i : fac){
    if(m/i >= n){
      chmax(max,(int)i);
    }
  }
  
  cout << max << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
struct L{ll x,y;}; int p[N];
struct node{int l,r;L s,tag;}a[N];
void build(int l,int r,int o)
{	a[o].l=l; a[o].r=r;
	if(l==r) return;
	int mid=(a[o].l+a[o].r)>>1;
	build(l,mid,o+o); build(mid+1,r,o+o+1);
}
void add(int l,int r,L g,int o)
{//	if(o==1) cerr<<"!!!"<<l<<" "<<r<<" "<<g.x<<" "<<g.y<<endl;
	if(l>r) return;
	if(a[o].l==l&&a[o].r==r){a[o].tag.x+=g.x;a[o].tag.y+=g.y;return;}
	int mid=(a[o].l+a[o].r)>>1;
	if(r<=mid) add(l,r,g,o+o);
	else if(l>mid) add(l,r,g,o+o+1);
	else add(l,mid,g,o+o),add(mid+1,r,L{g.x+g.y*(mid-l+1),g.y},o+o+1);
}
inline void down(int o)
{	a[o].s.x+=a[o].tag.x; a[o].s.y+=a[o].tag.y;
	if(a[o].l!=a[o].r) a[o+o].tag.x+=a[o].tag.x,a[o+o].tag.y+=a[o].tag.y,
	a[o+o+1].tag.x+=a[o].tag.x+a[o].tag.y*(a[o+o].r-a[o+o].l+1),
	a[o+o+1].tag.y+=a[o].tag.y;
	a[o].tag=L{0,0};
}
ll query(int pos,int o)
{	down(o);
	if(a[o].l==a[o].r) return a[o].s.x;
	int mid=(a[o].l+a[o].r)>>1;
	if(pos<=mid) return query(pos,o+o); else return query(pos,o+o+1);
}
#define dis(x,y) ((y-1)-(x-1)+m)%m
int main()
{	int n,m; ll ans=1e18; cin>>n>>m; build(1,m,1);
	for(rint i=1;i<=n;i++) scanf("%d",&p[i]);
	for(rint i=1;i<n;i++)
	{	if(p[i+1]>p[i])
		add(1,p[i],L{dis(p[i],p[i+1]),0},1),add(p[i+1]+1,m,L{dis(p[i],p[i+1]),0},1),
		add(p[i]+1,p[i+1],L{dis(p[i],p[i+1]),-1},1);
		else
		add(p[i]+1,m,L{dis(p[i],p[i+1]),-1},1),add(1,p[i+1],L{dis(1,p[i+1])+1,-1},1),
		add(p[i+1]+1,p[i],L{dis(p[i],p[i+1]),0},1);
	}
	for(rint i=1;i<=m;i++) ans=min(ans,query(i,1));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 14592
N = input()
a = [input() for i in range(N)]
#print a

dict={}


for i in range(N):
	if a[i] in dict:
		dict[ a[i] ]+=1 
	else:
		dict[ a[i] ]=1

#print dict

cnt=0
for key,value in dict.items():			
	cnt+=value%2

print cnt



Measured memory_bytes: 23152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> s(n, 0);
  rep(i, k){
    int d;
    cin >> d;
    rep(j, d){
      int sn;
      cin >> sn;
      s.at(sn-1)++;
    }
  }
  int ans = 0;
  rep(i, n){
    if(s.at(i) == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
cin>>N;
vector<int> card(N);

int a=0;
int b=0;
for(int i=0;i<N;i++)
  {
    cin>>card.at(i);
  }
sort(card.begin(),card.end());
reverse(card.begin(),card.end());
for(int i=0;i<N;i++)
  {
    if(i%2==0)a=a+card.at(i);
    else b=b+card.at(i);
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s,t;
	cin>>s>>t;
	ll i,j,c=0;
	for(i=0;i<s.length();i++){
		if(s[i]==t[i]){
			c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
// Problem : E - Rotation Matching
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif

int32_t main() 
{
	IAMSPEED
	int n,m; cin >> n >> m;
	FOR(i,1,m) {
		if(i*4<=n||n%2==1)cout<<i<<' '<<n-i+1 << '\n';
		else cout << i << ' ' << n-i << '\n';
	}
}



Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s;

    cin >> s;

    int a = 0, b = 0;

    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] != '1')
            {
                a++;
            }
        }
        else
        {
            if (s[i] != '0')
            {
                a++;
            }
        }
    }

    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] != '0')
            {
                b++;
            }
        }
        else
        {
            if (s[i] != '1')
            {
                b++;
            }
        }
    }

    cout << min(a, b) << endl;
}

Measured memory_bytes: 512
n = int(input())
xlist = []
ulist = []
for _ in range(n):
    x, u = input().split()
    xlist.append(float(x))
    ulist.append(u)

ans = 0
for x, u in zip(xlist, ulist):
    if u == 'JPY':
        ans += x
    else: # u == 'BTC'
        ans += x *  380000.0

print(ans)


Measured memory_bytes: 3060
from bisect import bisect, bisect_left

n = int(input())
a = list(map(int, input().split()))
b = [0]
for i in range(n):
	b.append(b[-1] + a[i])

ans = float("inf")
for j in range(2, n-1):
	c = []
	f = bisect(b, b[j]/2)
	f -= 1
	if f == 0 or j == 2:
		c += [b[1]-b[0], b[j]-b[1]]
	elif f == j-1:
		c += [b[j-1]-b[0], b[j]-b[j-1]]
	else:
		if abs(b[f]-b[0] - (b[j]-b[f])) <= abs(b[f+1]-b[0] - (b[j]-b[f+1])):
			c += [b[f]-b[0], b[j]-b[f]]
		else:
			c += [b[f+1]-b[0], b[j]-b[f+1]]

	l = bisect(b, b[j]+((b[n]-b[j])/2))
	l -= 1
	#print(l)
	if l == j or j == n-2:
		c += [b[j+1]-b[j], b[n]-b[j+1]]
	elif l == n-1:
		c += [b[n-1]-b[j], b[n]-b[n-1]]
	else:
		if abs(b[l]-b[j] - (b[n]-b[l])) <= abs(b[l+1]-b[j] - (b[n]-b[l+1])):
			c += [b[l]-b[j], b[n]-b[l]]
		else:
			c += [b[l+1]-b[j], b[n]-b[l+1]]

	ans = min(ans, max(c)-min(c))

print(ans)

Measured memory_bytes: 91652
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    x = [0] * N
    sumx = sum(A)
    x[0] = sumx - sum(A[1::2]) * 2
    for i in range(1, N):
        x[i] = A[i - 1] * 2 - x[i - 1]
    print(*x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63984
#include<bits/stdc++.h>
int n,m,i,j,h[1500],w[1500],p[1<<21],q[1<<21],x;
main(){
  while(scanf("%d%d",&n,&m),n){
    for(i=0;i<n;)scanf("%d",h+i++);
    for(i=0;i<m;)scanf("%d",w+i++);
    for(i=0;i<n;++i)for(x=0,j=i;j<n;++p[x])x+=h[j++];
    for(i=0;i<m;++i)for(x=0,j=i;j<m;++q[x])x+=w[j++];
    for(x=i=0;i<1<<21;p[i]=q[i++]=0)x+=p[i]*q[i];
    printf("%d\n",x);
  }
}

Measured memory_bytes: 19572
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				for(int m=1; m<=w; m++){
					line += "#";
				}
				for(int n=1; n<=h; n++){
					System.out.println(line);
				}
				System.out.println();
			}else break;
		}
	}
}

Measured memory_bytes: 27640
#ifdef _WIN32
	#include <vector>
	#include<set>
	#include<map>
	#include<algorithm>
	#include<stdio.h>
	#include<iostream>
#else
	#include <bits/stdc++.h>
#endif
using namespace std;

int main() {
	long N;
	cin >> N;
	vector<long> A(N);
	map<long, long> An;
	for (long i = 0; i < N; i++) {
		cin >> A.at(i);
		auto it = An.find(A.at(i));
		if (it == An.end()) {
			An[A.at(i)] = 1;
		}
		else {
			it->second++;
		}
	}
	map<long, long long> Cn; // そろっているときの個数
	map<long, long long> Dn; // 一個引いたときの個数
	for (auto it = An.begin(); it != An.end(); it++) {
		long a = it->first;
		long num = it->second;
		Cn[a] = num * (num - 1) / 2;
		Dn[a] = ( num - 1 ) * (num - 2) / 2;
	}
	long long fullcount = 0;
	for (auto it = An.begin(); it != An.end(); it++) {
		fullcount += Cn[it->first];
	}

	for (long k = 1; k <= N; k++) {
		long a = A[k - 1];
		long long count = fullcount - Cn[a] + Dn[a];
		cout << count << endl;
	}
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	cin>>s;
	for(int i=0;s.size()>i;i++){
		if(s.at(i)=='B'){
			s.at(i)='V';
			for(int j=i;0<=j;j--){
				if(s.at(j)!='V'){
					s.at(j)='V';
					break;
				}
			}
		}
	}
	for(int i=0;s.size()>i;i++){
		if(s.at(i)=='1'||s.at(i)=='0'){
			cout<<s.at(i);
		}
	}
	cout<<endl;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 125
# https://atcoder.jp/contests/abc125
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

cache = {}


def gcd(a, b):
    if a not in cache:
        cache[a] = {}
    if b in cache[a]:
        return cache[a][b]
    if b == 0:
        cache[a][b] = a
        return a
    n = gcd(b, a % b)
    cache[a][b] = n
    return n

def main_lte(N, An):
    if N == 2:
        n = max(An[0], An[1])
        print(n)
        return
    nn = [An[0]] * N
    nn[0] = An[1]
    for i in range(1, N):
        for j in range(N):
            if i == j:
                continue
            nn[j] = gcd(nn[j], An[i])
    print(int(max(nn)))

def main(N, An):
    if N == 2:
        n = max(An[0], An[1])
        print(n)
        return
    nn0 = gcd(An[0], An[1])
    nn1 = set((An[0], An[1]))
    for i in range(2, N):
        t1 = nn0
        nn0 = gcd(nn0, An[i])
        t2 = [gcd(n, An[i]) for n in nn1]
        nn1 = set(t2)
        nn1.add(t1)
    n = max(nn1)
    print(int(n))

N = i2n()
An = i2nn()
main(N, An)


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

int main(){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int s1 = h1 * 60 + m1;
  int s2 = h2 * 60 + m2;
  cerr<<s1 << " "<< s2<<endl;
  cout << s2 - s1 - k << endl;
}



Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

map<int,int> mp;

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif
    int n,x;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&x);
        if( mp.find(x) == mp.end() )    mp[x] = 1;
        else    mp[x]++;
    }
    LL a,b = -1;
    bool f = 1;
    auto it = mp.end();
    for( it-- ; 1 ; it-- ){
        //printf("key = %d , cnt = %d\n",it->first,it->second);
        if( it->second >= 2 ){
            if( f ){
                a = it->first;
                it->second -= 2;
                f = 0;
            }

            if( !f  && it->second >= 2 ){
                b = it->first;
                it->second;
                break;
            }
        }
        if( it == mp.begin() )  break;
    }
    if( b != -1 )
        cout<<a*b<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 4992
//TEMPLATE FOR CSES PROBLEMSET
//PROBLEM LINK:
//PROBLEM PATH: 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
constexpr ll MAXN = 1e6;
constexpr ll inf = 2e9;

int main()
{	
	ios::sync_with_stdio(false); 
	cin.tie(0);
	ll a,b,c,d;
	ll ans = 0 ;
	cin>>a>>b>>c>>d;
	ll aux1 = a * c;
	ll aux2 = a * d;
	ll aux3 = b * c;
	ll aux4 = b * d;
	cout<<max({aux1, aux2, aux3, aux4});
}


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

int main() {
  int n;
  cin >> n;
  int like[n + 1];
  fill(like, like + 1 + n, 0);
  int count = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    like[i] = a;
    if (like[a] == i) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


int main()
{
    string s;
    cin >> s;
    int res = 0;
    int cur = 0;
    rep(i,3) {
        if(s[i] == 'R') cur++;
        else {
            chmax(res, cur);
            cur = 0;
        }
    }
    chmax(res, cur);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int sum=0;
	for (int i=0;i<3;i++)
		if(a[i]==b[i])
		{
			sum++;
		 } 
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
T = list(t)
sl = len(s)
tl = len(t)
ans = 10**18

for i in range((sl-tl)+1):
  cnt = 0
  S = list(s[i:i+tl])
  for a,b in zip(S,T):
    if a != b:
      cnt += 1
  if ans > cnt:
    ans = cnt
print(ans)

Measured memory_bytes: 9072
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int D = sc.nextInt();
    int G = sc.nextInt();
    int[] p = new int[D];
    int[] c = new int[D];

    for (int i = 0; i < D; i++) {
      p[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }

    System.out.println(solve(D, G, p, c));
  }

  private static int solve(int D, int G, int[] p, int[] c) {
    int ans = Integer.MAX_VALUE;

    // i桁の値が1なら問題iを完全に解く
    for (int mask = 0; mask < (1 << D); mask++) {
      int score = 0, num = 0, rest_max = -1;
      // maskに対応したスコアを算出する
      for (int i = 0; i < D; i++) {
        if ((mask >> i & 1) == 1) {
          score += 100 * (i + 1) * p[i] + c[i];
          num += p[i];
        } else {
          // 中途半端に解く問題 (完全に解く問題以外で最大の配点となる問題)
          rest_max = i;
        }
      }

      if (score < G) {
        int s1 = 100 * (rest_max + 1);
        int need = (G - score + s1 - 1) / s1;
        if (need >= p[rest_max]) {
          // このmaskと中途半端に解く問題の組合せでは総合スコアをG以上にできない
          continue;
        }

        num += need;
      }
      ans = Math.min(ans, num);
    }

    return ans;
  }
}

Measured memory_bytes: 22740
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  while (cin >> N >> S) {
    char p = '-';
    int res = 0;
    for (char c : S) {
      if (c != p) {
        ++res;
        p = c;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 512
import math

def Koch(Px, Py, Qx, Qy, n) :
    if n == 0 :
        return
    else :
        Ax = (2 * Px + Qx) / 3
        Ay = (2 * Py + Qy) / 3
        Bx = (Px + 2 * Qx) / 3
        By = (Py + 2 * Qy) / 3
        Cx = Ax + (Bx - Ax) * math.cos(math.pi/3) - (By - Ay) * math.sin(math.pi/3) 
        Cy = Ay + (Bx - Ax) * math.sin(math.pi/3) + (By - Ay) * math.cos(math.pi/3)
        
        Koch(Px, Py, Ax, Ay, n-1)
        print(Ax, Ay)
        Koch(Ax, Ay, Cx, Cy, n-1)
        print(Cx, Cy)
        Koch(Cx, Cy, Bx, By, n-1)
        print(Bx, By)
        Koch(Bx, By, Qx, Qy, n-1)

n = int(input())
print(0, 0.00000000)
Koch(0.00000000, 0.00000000, 100.00000000, 0.00000000, n)
print(100.00000000, 0.00000000)



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

int k;
vector<string> vec;
string str;

int main(void){
	cin >> str;
	scanf("%d",&k);
	int n=str.size();
	for(int i=0;i<n;i++){
		string tmp="";
		for(int j=0;(j<k && i+j<n);j++){
			tmp+=str[i+j];
			vec.push_back(tmp);
		}
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	cout << vec[k-1] << endl;
	return 0;
}

Measured memory_bytes: 1660