akhauriyash/Code-Regression huggingface dataset:
import itertools

N= int(input())
D = list(map(int,input().split()))

if any((D+[0,0,12]).count(i) >2 for i in range(0,13)):
    print(0)
    exit(0)


l= [0]
if D.count(12):
    l.append(12)

can_select=[]
for i in range(1,12):
    if (D).count(i) ==2:
        l.append((i))
        l.append((24 - i))

    if D.count(i)==1:
        can_select.append(i)

def change12(v):
    return min(24-v,v)

def get_closest(l):
    min_val =24
    for i in range(len(l)-1):
        min_val= min(change12(l[i+1]-l[i]),min_val)

    return min(change12(l[-1] - l[0]),min_val )

tmp_ans=0
for seed in list(itertools.product(range(2), repeat=len(can_select))):
    tmp_list = list(l)
    for i,val in enumerate(can_select):
        if seed[i]==1:
            tmp_list.append(val)
        else:
            tmp_list.append(24-val)
    tmp_list.sort()
    tmp_ans =max(tmp_ans, get_closest(tmp_list))



print(tmp_ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll x;
  cin >> x;
  ll n = (x - 400) / 200;
  cout << 8 - n << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int r, g, b, n;
	cin>>r>>g>>b>>n;
	ll ans=0;
	REP(i, n+1){
		REP(j, n+1){
			int tmp=i*r+j*g;
			if(n>=tmp && (n-tmp)%b==0){
				++ans;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  int64_t N,ans=0,i=0; cin>>N;
  N-=3;
  while(N>=0){
    ans+=COM(N+i,i);
    ans%=MOD;
    i++;
    N-=3;
  }
  cout<<ans;
}

Measured memory_bytes: 15580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,Q,ans;
int a[15];

struct Query {
	int a,b,c,d;
}q[55];

void dfs(int x) {
	if(x == n+1) {
		int res = 0;
		for(int i = 1;i <= Q;i++) {
			if(a[q[i].b]-a[q[i].a] == q[i].c) res += q[i].d;
		}
		ans = max(ans,res);
		return;
	}
	for(int i = a[x-1];i <= m;i++) {
		a[x] = i; dfs(x+1);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> Q;
	for(int i = 1;i <= Q;i++) {
		cin >> q[i].a >> q[i].b >> q[i].c >> q[i].d;
	}
	a[0] = 1;
	dfs(1);
	cout << ans;
} 

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N,K;
    cin>>N>>K;
    int ans=1;
    rep(i,N){
        if(ans<K)ans*=2;
        else ans+=K;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    long long a;
    string b;
    cin>>a>>b;

    b.erase(b.size()-3,1);
    ll B=stoi(b);


    cout<<a*B/100<<endl;
}


Measured memory_bytes: 3616
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    }
}




Measured memory_bytes: 26140
#include <iostream>

using namespace std;
const int nmax=100005;
int p[2*nmax],used[2*nmax];
int n,x,i;
int main()
{
    cin>>n>>x;
    if(x==1||x==2*n-1)
    {
        cout<<"No";
        return 0;
    }
    if(n==2)
    {
        cout<<"Yes\n";
        cout<<"1 2 3";
        return 0;
    }
    if(x==2*n-2)
    {
        p[n]=x;
        p[n+1]=x+1;
        p[n+2]=x-1;
        p[n-1]=x-2;
        used[x]=used[x-1]=used[x-2]=used[x+1]=1;
    }
    else
    {
        p[n]=x;
        p[n+1]=x-1;
        p[n+2]=x+1;
        p[n-1]=x+2;
        used[x]=used[x-1]=used[x+1]=used[x+2]=1;
    }
    int j=1;
    cout<<"Yes\n";
    for(i=1;i<=2*n-1;i++)
    {
        if(!p[i])
        {
            while(used[j])
              j++;
           used[j]=1;
          p[i]=j;
        }
        cout<<p[i]<<' ';

    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
const int maxn = 1e3 + 100;
const int mod = 1e9 + 7;
int dp[maxn][maxn];
int32_t main() 
{
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.txt");
#endif
	int h,w;
	cin >> h >> w;
	dp[1][1] = 1;
	for(int i = 1;i<=h; i++)
		for (int j = 1; j <= w; j++)
		{
			char m;
			cin >> m;
			if (i == 1 && j == 1)continue;
			if(m == '.') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	cout << dp[h][w]<<'\n';
}


Measured memory_bytes: 4608
// abc051_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    struct Edge {
        int u, v, w;
        Edge() {}
        Edge(int u, int v, int w) : u(u), v(v), w(w) {}
    };

    int N, M;
    cin >> N >> M;

    vector<Edge> edges(M);
    vector<vector<int>> dist(N, vector<int>(N, INF));
    REP(i, N) dist[i][i] = 0;

    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[i] = {a, b, c};
        dist[a][b] = c;
        dist[b][a] = c;
    }

    REP(k, N) REP(i, N) REP(j, N) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

//    REP(i, N) print(dist[i]);

    int ans = 0;
    REP(i, M){
        if (dist[edges[i].u][edges[i].v] < edges[i].w){
            ans++;
        }
    }

    print(ans);


    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

ll dp[51][51][2501]={0};

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

    dp[0][0][0]=1;
    rep(i,n)rep(j,n)rep(k,2501)
    {
        ll add=dp[i][j][k];
        dp[i+1][j+1][k+x[i]]+=add;
        dp[i+1][j][k]+=add;
    }

    ll ans=0;
    for(int i=1; i<=n; ++i) ans+=dp[n][i][a*i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 50048
s=input()
S=""
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S+="A"
        i+=1
    elif i+1<leng and s[i]=="B" and s[i+1]=="C":
        S+="B"
        i+=2
    else:
        S+="C"
        i+=1
T=S[::-1]
l=[0]*len(T)
ans=0
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
        ans+=l[i]
if T[-1]=="A":
    ans+=l[-1]
print(ans)


Measured memory_bytes: 6596
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    int res = 0;
    rep(i, N) {
        int x;
        cin >> x;
        res += min(x, K - x) * 2;
    }
    cout << res << endl;
    return 0;
}

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

Y = X[::]
Y.sort()

m = n // 2
median = (Y[m] + Y[m - 1]) / 2

for x in X:
    if x < median:
        print(Y[m])
    else:
        print(Y[m-1])



Measured memory_bytes: 105140
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
p = [V[i] - C[i] for i in range(N)]
p.sort(reverse=True)

res = 0
for i in p:
        if i <= 0:
                break
        res += i
print(res) 


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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
  	cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  cout << a.at(n/2) - a.at(n/2 -1) << endl;
}


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

#define ll long long

bool cmp(pair<int, int> a, pair<int, int> b){
    return a.first < b.first;
}

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

    pair<int, int> arr[n+1];

    int x;
    for(int i = 1; i <= n; i++){
        cin >> x;
        arr[i] = make_pair(x, i);
    }

    sort(arr+1, arr+1+n, cmp);

    for (int i = 1; i <= n; i++){
        cout << arr[i].second << endl;
    }


    return 0;
}



Measured memory_bytes: 1664
#include <stdio.h>

int main(void){

  long a,b,c,d;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
  long answer = a*b;
  if (c*d > answer) {
    answer = c*d;
  }
  printf("%ld\n", answer);

  return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int rs[26], rt[26];
  fill(rs, rs+26, 0);
  fill(rt, rt+26, 0);

  string ans = "Yes";
  for ( int i = 0; i < s.length(); i++ ) {
    int si = s[i]-'a';
    int ti = t[i]-'a';
    rs[si]++;
    rt[ti]++;
    if ( rs[si] != rt[ti] ) {
      ans = "No";
      break;
    }
  }

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


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int l;

int n = 20;

vector<tuple<int, int, int>> ans;

int main(void) {
  // Here your code !
  scanf("%d", &l);

  int r;

  for (ll i = 1; i <= n; ++i) {
    if ((1 << i) > l) {
      r = i - 1;
      break;
    }
  }

  for (int i = 0; i < r; ++i) {
    int node = i + 1;
    ans.push_back(make_tuple(node, node + 1, 0));
    ans.push_back(make_tuple(node, node + 1, 1 << i));
  }

  for (int i = r; i >= 1; --i) {
    if (l - (1 << r) >= (1 << (i - 1))) {
      ans.push_back(make_tuple(i, r + 1, l - (1 << (i - 1))));
      l -= 1 << (i - 1);
    }
  }

  printf("%d %d\n", r + 1, ans.size());

  for (auto &e: ans) {
    printf("%d %d %d\n", get<0>(e), get<1>(e), get<2>(e));
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = Integer.parseInt(scan.next());
        String s = scan.next();
        scan.close();

        String[] ss = s.split("");

        if (ss.length <= k) {
            System.out.println(s);
        } else {
            for (int i = 0; i < k; i++) {
                System.out.print(ss[i]);
            }
            System.out.println("...");
        }

    }

}


Measured memory_bytes: 35676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <stack>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  string s;
  cin >> s;
  stack<char> stc;

  for (auto itr : s) {
    if (itr != 'B') {
      stc.push(itr);
    } else {
      if (stc.size() > 0) {
        stc.pop();
      } else {
        ;
      }
    }
  }

  vector<char> c;
  while (stc.size() > 0) {
    char tmp = stc.top();
    stc.pop();
    c.pb(tmp);
  }

  for (int i = c.size() - 1; i >= 0; --i) {
    cout << c[i];
  }
  END;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main() {
  int n; cin >> n;
  map<string, ll> mp;
  rep(i,n){
    string s; cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto p : mp){
    ans += p.second * (p.second-1)/2;
  }
  cout << ans << endl;
}



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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vector <ll> arr(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) cin >> arr[i], sum += arr[i];
  vector <ll> div;
  for (ll d = 1; d * d <= sum; d++) {
    if (sum % d) continue;
    div.pb(d);
    if (d * d != sum) div.pb(sum / d);
  }
  ll ans = 1;
  for (ll d: div) {
    vector <ll> val(n);
    ll sum1 = 0;
    ll sum2 = 0;
    for (int i = 0; i < n; i++) {
      sum1 += d - (arr[i] % d);
      val[i] = arr[i] % d;
    }
    sort(all(val));
    ll need = 0;
    for (ll elem: val) {
      if (sum1 == sum2) continue;
      need += elem;
      sum1 = sum1 - (d - elem);
      sum2 += elem;
    }
    if (sum1 == sum2 and need <= k) ans = max(ans, d);
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=100050;
int n,m;
string s;
vector<int> ans;
int main()
{
	cin>>n>>m;
	cin>>s;
	int temp=0,flag=1;
	for(int i=0;i<=n;i++)
	{
		if(s[i]=='1')
		{
			temp++;
			if(temp>=m) 
			{
				flag=0;
			}
		}
		else temp=0;
	}
	if(!flag) puts("-1");
	else
	{
		int temp=n;
		while(temp)
		{
			if(s[max(temp-m,0)]=='0') ans.push_back(min(m,temp)),temp=max(temp-m,0);
			else
			{
				int t=m;
				while(s[temp-t]!='0') t--;
				temp=temp-t;
				ans.push_back(t);
			}
		}
		for(int i=ans.size()-1;i>=0;i--) cout<<ans[i]<<" ";
		puts("");
	}
	return 0;
}


Measured memory_bytes: 1144
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func partseFloat(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	x, y := getInt(), getInt()

	fmt.Println(x + y/2)
}


Measured memory_bytes: 640
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const a: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const map = {};
    for (let i = 0, len = n - 1; i < len; i++) {
      const ai = a[i];
      if (!map[ai]) {
        map[ai] = 0;
      }
      map[ai]++;
    }
    for (let i = 1; i <= n; i++) {
      console.log(map[i] ? map[i] : 0);
    }
  }
}
Main.main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 63356
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)
#define AZ(x)        x.begin(),x.end()
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510
 
const ll mod=1e9+7,N=1e5+5,INF = 1e18;

ll power(ll a,ll b)
{
    a = a%mod;
    ll result = 1;

    while(b)
    {
        if(b&1)
            result = (result*a)%mod;
        b >>= 1, a = (a*a)%mod;
    }
    return result;
}

int main() 
{ 
    BOOST

    int a,b;
    cin>>a>>b;

    if(a>=13)
        cout<<b<<"\n";
    else if(a>=6 && a<=12)
        cout<<(b/2)<<"\n";
    else cout<<0<<"\n";
    return 0;    
} 

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

#define ll long long 
#define pb push_back
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()

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

	string s; cin >> s;
	int r = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'R') {
			r++;
		}
	}
	if (r != 2) cout << r << "\n";
	else {
		if (s == "RSR") cout << "1\n";
		else cout << "2\n";
	}
	return 0;
}

Measured memory_bytes: 3576
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
-- templete

bubblesort xs' = sub (0,xs')
  where
    sub (r, []) = r
    sub (r, xs) = sub $ subsub (r, xs)
    subsub (r, [x]) = (r, [])
    subsub (r, (x:y:ys)) = if x>y then (y:) <$> subsub (r+1, (x:ys)) else (x:) <$> subsub (r, (y:ys))

main = do
    n <- getInt
    when (n/=0) $ do
        a <- replicateM n getInt
        print $ bubblesort a
        main




Measured memory_bytes: 4524
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const long long INF = 1LL<<60;
int N;
vector<long long> A;

long long solve() {
    vector<long long> left(N+1, 0), right(N+1, 0);
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            left[i+1] = left[i] + A[i];
            right[i+1] = right[i] + A[N-i-1];
        }
        else left[i+1] = left[i], right[i+1] = right[i];
    }
    vector<long long> dp(N+1, -INF);
    dp[0] = 0;
    for (int i = 2; i <= N; i += 2) {
        chmax(dp[i], dp[i-2] + A[i-1]);
        chmax(dp[i], left[i-2] + max(A[i-1], A[i-2]));
    }

    if (N % 2 == 0) return dp[N];
    long long res = -INF;
    for (int i = 0; i <= N; i += 2) {
        chmax(res, dp[i] + right[N-i-1]);
    }

    //COUT(left); COUT(right); COUT(dp);

    return res;
}

int main() {
    while (cin >> N) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        cout << solve() << endl;
    }
}

















Measured memory_bytes: 9540
#include<stdio.h>

int main() {

	int n ;
	int x ;
	int t ;
	
	scanf("%d",&n);
	scanf("%d",&x);
	scanf("%d",&t);

	int times = (n + x - 1) / x;
	
	if (times * x >= n) {

		printf("%d", times*t);

	}
	
	
	return 0;

}

Measured memory_bytes: 2112
import java.util.*;

public class Main {
    int map[][];
    int ans = 0;

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        map = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            map[a - 1][b - 1] = 1;
            map[b - 1][a - 1] = 1;
        }

        foo(1, n, new int[n], new BitSet());

        System.out.println(ans);
    }

    private void foo(int p, int n, int data[], BitSet bs) {
        if (p == n) {
            check(n, data);
            return;
        }

        for (int i = 1; i < n; i++) {
            if (!bs.get(i)) {
                data[p] = i;
                bs.set(i);
                foo(p + 1, n, data, bs);
                bs.clear(i);
            }
        }
    }

    private void check(int n, int data[]) {
        for (int i = 0; i < n - 1; i++) {
            if (map[data[i]][data[i + 1]] != 1) {
                return;
            }
        }

        ans++;
    }

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().main(sc);
        } catch (Exception e) {
            throw e;
        }
    }
}


Measured memory_bytes: 24088
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    
    if (a>9 || b>9) {
      System.out.println("-1");
      return;
    } else {
      int ans = a*b;
      System.out.println(ans);
    }
    
  }
}


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

int N;
multiset<int> ms;
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) {
        int A; cin >> A;
        auto it = ms.lower_bound(A);
        if (it==ms.begin()) ms.insert(A);
        else {
            ms.erase(--it);
            ms.insert(A);
        }
    }
    cout << ms.size() << endl;
}

Measured memory_bytes: 8280
use std::io;
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N: i64 = iter.next().unwrap().parse().unwrap();
    let K: i64 = iter.next().unwrap().parse().unwrap();

    let ans = if N%K==0 {0}else{1};
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
struct segtree{
private:
	T init;
	int n;
	function<T(T,T)> op;
	vector<T>arr;
	vector<T>st;
	vector<T>lz;
	void build(int lo,int hi,int u){
		if(lo==hi){
			st[u]=arr[lo];
		}
		else{
			int mi=(hi+lo)>>1;
			build(lo,mi,u<<1);
			build(mi+1,hi,u<<1|1);
			st[u]=op(st[u<<1],st[u<<1|1]);
		}
	}
	void apply(T x,int u,int lo,int hi){
// 		st[u]+=x*(hi-lo+1);
// 		st[u]+=x;
		st[u]=x;
// 		st[u]=x*(hi-lo+1);
// 		lz[u]+=x;
		lz[u]=x;
	}
	void push(int u,int lo,int hi){
		if(lz[u]!=init){
			int mi=(lo+hi)>>1;
			apply(lz[u],u<<1,lo,mi);
			apply(lz[u],u<<1|1,mi+1,hi);
			lz[u]=init;
		}
	}
	void modify(int l,int r,T x,int u,int lo,int hi){
		if(r<lo||l>hi||l>r)return;
		if(l<=lo&&r>=hi){
			apply(x,u,lo,hi);
			return;
		}
		push(u,lo,hi);
		int mi=(lo+hi)>>1;
		if(mi>=r){
			modify(l,r,x,u<<1,lo,mi);
		}
		else if(mi<l){
			modify(l,r,x,u<<1|1,mi+1,hi);
		}
		else{
			modify(l,mi,x,u<<1,lo,mi);
			modify(mi+1,r,x,u<<1|1,mi+1,hi);
		}
		st[u]=op(st[u<<1],st[u<<1|1]);
	}
	T query(int l,int r,int u,int lo,int hi){
		if(l>r||l>hi||r<lo)return init;
		if(l<=lo&&r>=hi){
			return st[u];
		}
		push(u,lo,hi);
		int mi=(hi+lo)>>1;
		if(mi>=r){
			return query(l,r,u<<1,lo,mi);
		}
		else if(mi<l){
			return query(l,r,u<<1|1,mi+1,hi);
		}
		else{
			return op(query(l,mi,u<<1,lo,mi),query(mi+1,r,u<<1|1,mi+1,hi));
		}
	}
public:
	segtree(T n,function<T(T,T)> op):n(n),st(n*4),op(op),lz(n*4){
		init=T();
	}
	segtree(vector<T> v,function<T(T,T)> op):n(v.size()),st(v.size()*4),op(op),lz(v.size()*4){
		init=T();
		arr=v;
		build(0,n-1,1);
	}
	T query(int l,int r){
		return query(l,r,1,0,n-1);
	}
	T query(int p){
		return query(p,p);
	}
	void setinit(T x){
		init=x;
		for(int i=0;i<4*n;i++){
			st[i]=init;
			lz[i]=init;
		}
	}
	void modify(int l,int r,T x){
		modify(l,r,x,1,0,n-1);
	}
	void modify(int p,T x){
		modify(p,p,x);
	}
	void debug(){
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				cout<<i<<" "<<j<<" "<<query(i,j)<<"\n";
			}
		}
	}
};
int main(){
	int n,q;
	cin>>n>>q;
	segtree<int> seg(n,[](int a,int b){
		return min(a,b);
	});
	seg.setinit(INF);
	while(q--){
		int c;
		cin>>c;
		if(c){
			int l,r;
			cin>>l>>r;
			cout<<seg.query(l,r)<<"\n";
		}
		else{
			int l,r,x;
			cin>>l>>x;
			seg.modify(l,x);
		}
	}
}




Measured memory_bytes: 5968
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
ll i, n, m, k, ans;
vector<ll> divisor;

int main() {
    scanf(" %lld", &n);
    rep(1,sqrt(n)+1) if (n%i == 0) {
        divisor.push_back(i);
        divisor.push_back(n/i);
    }
    sort(divisor.begin(), divisor.end());
    for(auto it = divisor.begin(); it != divisor.end(); it++) {
        ll dim = *it;
        ll b = -dim/2; ll a = dim+b;
        while(true) {
            ll val = pow(a, 5) - pow(b, 5);
            if (val == n) {
                printf("%lld %lld\n", a, b); exit(0);
            } else if (abs(val) > n) {
                break;
            } else {
                a++; b++;
            }
        }
    }
}

Measured memory_bytes: 4224
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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



struct Card{char suit, num;};

void printCards(vector<Card> &a){
    int n = SZ(a);
    REP(i, n){
        if(i) cout << " ";
        cout << a[i].suit << a[i].num;
    }
    cout << "\n";
}

void bubbleSort(vector<Card> &a){
    int n = SZ(a);
    bool flag = true;
    for(int i = 0; flag && (i < n); ++i){
        flag = false;
        for(int j = n-1; j >= i + 1; --j){
            if(a[j-1].num > a[j].num){
                swap(a[j-1], a[j]);
                flag = true;
            }
        }
    }
}

void selectionSort(vector<Card> &a){
    int n = SZ(a);
    REP(i, n){
        int minidx = i;
        FOR(j, i, n){
            if(a[j].num < a[minidx].num)
                minidx = j;
        }
        if(i != minidx)
            swap(a[i], a[minidx]);
    }
}

bool isStable(vector<Card> &a, vector<Card> &b){
    //a.bはソート済み。aは安定、bを調べる。個数は同じ
    REP(i, a.size()){
        if(a[i].suit != b[i].suit) return false;
    }
    return true;
}

int main(){
    int n; cin >> n;
    vector<Card> A1(n), A2;
    REP(i, n) cin >> A1[i].suit >> A1[i].num;
    A2 = A1;
    bubbleSort(A1);
    selectionSort(A2);
    printCards(A1);
    cout << "Stable" << "\n";//バブルは安定
    printCards(A2);
    cout << (isStable(A1, A2) ? "Stable" : "Not stable") << "\n";
    return 0;
}



Measured memory_bytes: 3140
# include <vector>
# include <iostream>


using namespace std;


pair<int, int> add(pair<int, int> v1, pair<int, int> v2) {
    return make_pair(v1.first+v2.first, v1.second+v2.second);
}


pair<int, int> frac(pair<int, int> v1, pair<int, int> v2) {
    return make_pair(v1.first-v2.first, v1.second-v2.second);
}


int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    pair<int, int> va, vb, vc;

    va = make_pair(x2-x1, y2-y1);

    pair<int, int> c = add(make_pair(x2, y2), make_pair(-va.second, va.first));
    pair<int, int> d = frac(c, va);

    cout << c.first << " " << c.second << " " << d.first << " " << d.second << endl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    a, b = mi()
    if a >= 13:
        print(b)
    elif a >= 6:
        print(b//2)
    else:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
// This  Program is made by Jan(Codezebra)
#include<bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
using namespace std;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d)){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}



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

	int k;
	int a[]={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};

	scanf("%d",&k);
	printf("%d", a[k-1]);
	return 0;
}

Measured memory_bytes: 128
#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 a, b, c, d; cin >> a >> b >> c >> d;

	int e = a / d;
	if(a % d) e += ((a % d) / (a % d));
	int f = c / b;
	if(c % b) f += ((c % b) / (c % b));

	cout << ((e >= f) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
bool check(int num){
    int cnt=0;
    for(int i=1;i<=num;i++){
        if(num%i==0)cnt++;
    }
    if(cnt==8)return true;
    else return false;
}
int main(void){
int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i+=2){
    if(check(i)){
        ans++;
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define eps 1e-9
using namespace std;
typedef struct
{
    double x;
    double y;
}Point;
double area(Point a,Point b,Point c)
{
    return a.x*b.y+c.x*a.y+b.x*c.y-c.x*b.y-a.x*c.y-b.x*a.y;
}
int main()
{
    Point a,b,c,tar;
    while(cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>tar.x>>tar.y)
    {
        double sum=abs(area(a,b,c));
        double cmp=abs(area(a,b,tar))+abs(area(a,c,tar))+abs(area(b,c,tar));
        if(cmp-sum<eps)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int n = Integer.parseInt(strlist[0]);
		int k = Integer.parseInt(strlist[1]);

		int answer = k;

		for(int i=0; i<n-1; i++){
			answer = answer * (k-1);
		}

		System.out.println(answer);

	}

}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 
signed main(){
  int a,b,e=0;
  cin>>a>>b;
  vector<char> c(b);
  string d;
  for(int i=0;i<b;i++)
  cin>>c.at(i);
  for(int i=a;i<100000;i++){
    d=to_string(i);
    for(int j=0;j<d.size();j++){
      for(int k=0;k<b;k++){
        if(d.at(j)==c.at(k)){
          e=1;
          break;
        }
      }
      if(e==1)
        break;
    }
    if(e==0){
      cout<<i<<endl;
      break;
    }
    e=0;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<queue>

using namespace std;

void solve(stack <int> s , int r ){
  
  
  int p[r] ,c[r];

  for(int i = 0 ; i < r ; i++ ){
    cin >> p[i] >> c[i];
    p[i]--;
  }
  
  for(int i = 0 ; i < r ; i++ ){
    stack<int> s_sita;
    stack<int> s_ue;
    
    

    while(p[i]-- > 0){
      int a = s.top();
      s.pop();
      //cout << "push_sita:" << a << endl;
      //cout << "p:" << p[i] << endl;
      //cout << "size" << s.size() << endl;
      s_sita.push(a);
    }

    while(c[i]-- > 0){
      int a =s.top();
      s.pop();
      //cout << "push_ue:" << a << endl;
      //cout << "c" << c[i] << endl;
      //cout << "size" << s.size() << endl;
      s_ue.push(a);
    }
    
    while(!s_sita.empty()){
      s.push(s_sita.top());
      //cout << "s.push" << s_sita.top() << endl;
      s_sita.pop();
    }
    
    while(!s_ue.empty()){
      s.push(s_ue.top());
      //cout << "s.push" << s_ue.top() << endl;
      s_ue.pop();
    }
    
    //cout << "size" << s.size() << endl;

    //cout << endl;

  }
    
  cout << s.top() << endl;

  return;

}

int main(){

  int r , n ;

  
  while(1){

    cin >> n >> r;
    if(r == 0 || n == 0)
      break;

    else{
      stack <int> s;
      for(int i = 1 ; i <= n ; i++ ){
        s.push(i);
        //cout << i << endl;
      }
      solve(s,r);
      //cout << "done" << endl;
    }
  }

  return 0;
}

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

int N;
int W[100];
int SUM[101];

int main() {
    cin >> N;
    rep(i, N) cin >> W[i];

    for (int i = 1; i <= N; i++) {
        SUM[i] += SUM[i - 1] + W[i - 1];
    }

    // rep(i, N + 1) {
    //     cout << SUM[i] << endl;
    // }

    int diff = 1000000;
    for (int i = 1; i <= N - 1; i++) {
        int left = SUM[i];
        int right = SUM[N] - left;
        // printf("l: %d r: %d\n", left, right);
        diff = min(diff, abs(right - left));
    }

    cout << diff << endl;
}

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

using namespace std;
typedef long long ll;
typedef long  double lb;
int mod=1e9+7;
const int N=1e5+5;
bool cmp(int x,int y){return x>y;}
int main()
{
    ll a,b;cin>>a>>b;
    ll k=a%b;
    ll ans=k;
    ans=min(ans,b-ans);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import bisect
import sys
A, B, Q = map(int,input().split())

S = [-10**18] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18]
T = [-10**18] + list(map(int, (sys.stdin.readline() for _ in [0]*B))) + [10**18]





for _ in range(Q):
    x = int(input())
    ans = 10**18
    for i in range(2):
        if i == 0:
            a = S
            b = T
        elif i== 1:
            a = T
            b = S

        idx_x = bisect.bisect_left(a,x)
        for j in range(2):
            ax = a[idx_x-j]
            idx_a = bisect.bisect_left(b,ax)
            for k in range(2):
                bx = b[idx_a-k]
                ans = min(ans, abs(ax-x)+abs(bx-ax))
    print(ans)

Measured memory_bytes: 67940
INF = 5000
$h = 0
$w = 0

def bfs(bord,a)
	walks = [[1,0],[-1,0],[0,1],[0,-1]]
	
	newpos = []
	queue = [a]
	
	while (!queue.empty?) do
		q = queue.shift
		walks.each{|ws|
			newpos[0] = q[0] + ws[0]
			newpos[1] = q[1] + ws[1]
			if newpos[0].between?(0,$h-1) and newpos[1].between?(0,$w-1) then
				if bord[newpos[0]][newpos[1]] > (bord[q[0]][q[1]]+1) then
					bord[newpos[0]][newpos[1]] = bord[q[0]][q[1]] + 1
					queue.push([newpos[0],newpos[1]])
				end
			end
		}
	end
	
end

loop{
	str = gets.split.map(&:to_i)
    if str.size != 2
        next
    end
    $h,$w = str[0],str[1]
	if ($h == 0 and $w == 0) then
		exit
	end
	a = [0,0]
	b = [0,0]
	bord = Array.new($h).map{Array.new($w,0)}

	$h.times{|y|	
		bord[y] = gets.chomp.split(//).map.with_index{|c,i|
			case c
			when "A" then
				a[0] = y
				a[1] = i
				0
			when "B" then
				b[0] = y
				b[1] = i
				INF
			when "." then
				INF
			else
				-1
			end
		}
	}
	bfs(bord,a)
	pat = gets.chomp
	bstep = 0
	flag = 0
	loop{
		pat.each_char{|ch|
			bstep += 1
			case ch
			when "2" then
				b[0] += b[0] < $h-1 ? 1:0
			when "4" then
				b[1] -= b[1] > 0 ? 1:0
			when "6" then
				b[1] += b[1] < $w-1 ? 1:0
			when "8" then
				b[0] -= b[0] > 0 ? 1:0
			when "5" then
			end
			if bord[b[0]][b[1]] != -1 and bstep >= bord[b[0]][b[1]] then
				print("#{bstep} #{b[0].to_s} #{b[1]}\n")
				flag = 1
				break
			end
		}
		if flag == 1 then
			break;
		end
		if bstep >= 500 then
			print "impossible\n"
			break
		end
	}
}

Measured memory_bytes: 6100
from numpy import argmax
import numpy as np
from collections import defaultdict

cross = np.cross

n = int(input())
H = [np.array([int(j) for j in input().split()]) for i in range(n)]

if n == 1:
    print(1)
    exit()
# else n == 2:
#     print(0.5)
#     print(0.5)
#     exit()

convex = [min(H, key=lambda x:x[1])]

for i in range(n):
    a = H[0] if (H[0] != convex[-1]).any() else H[-1]
    for b in H:
        ac = a-convex[-1]
        bc = b-convex[-1]
        cross_ = cross(ac, bc)
        if cross_ < 0 or (cross_ == 0 and np.linalg.norm(ac) < np.linalg.norm(bc)):
            a = b
    if (a == convex[0]).all():
        break
    convex.append(a)

ans = defaultdict(float)

for c, a, b in zip([convex[-1]]+convex[:-1], convex, convex[1:] + [convex[0]]):
    ca = c-a
    ba = b-a
    i = np.inner(ca, ba)
    n = np.linalg.norm(ca) * np.linalg.norm(ba)
    ans[tuple(a)] = (np.pi - np.arccos(np.clip(i/n, -1, 1))) / (2*np.pi)

for i in H:
    print(ans[tuple(i)])


Measured memory_bytes: 14236
n = int(input())
s = [input() for _ in range(n)]
start_b = len([i for i in s if i[0] == "B" and i[-1] != "A"])
end_a = len([i for i in s if i[-1] == "A" and i[0] != "B"])
both = len([i for i in s if i[0] == "B" and i[-1] == "A"])
include_ab = sum([i.count("AB") for i in s])

if both:
  if end_a:
    if start_b:
      end_a -= 1
      start_b -= 1
      include_ab += (both+1)
    else:
      end_a -= 1
      include_ab += both
  else:
    if start_b:
      start_b -= 1
      include_ab += both
    else:
      include_ab += (both - 1)
print(include_ab + min(start_b,end_a))

Measured memory_bytes: 3700