akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    ll n;cin >> n;
    vector<ll> t(n);
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    ll ans=0;
    if(t.size()==1){
        cout << t[0];
        return 0;
    }else{
        while(t.size()>1){
            ll a,b;
            a=t.back();
            t.pop_back();
            b=t.back();
            t.pop_back();
            t.push_back(lcm(a,b));
        }
        cout << t[0];
        return 0;
    }
    cout << ans;

    return 0;
}

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

const int mod = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    vector<ll>s(n+1);
    rep(i,n) {
        s[i+1] = s[i]+a[i];
        s[i+1] %= mod;
    }
    ll ans = 0;
    rep(i,n-1) {
        ans += a[i]*(s[n]-s[i+1]+mod)%mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6300
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;

using namespace std;
int inf=1e9;
ll p=998244353;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
   // freopen("input.txt","r",stdin);
    int n1;
    cin>>n1;
    string s;
    cin>>s;
    int n;
    n=s.size();
    ll ans=1;
    ll a=0,b=0,c=0;
    ll md1=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            a++;
        }
        else if(s[i]=='G') b++;
        else c++;
        ll mn=min(a,min(b,c));
        ll mx=max(a,max(b,c));
        ll md=a+b+c-mn-mx;
        if(md>md1){
            ans*=(mx-md+1);
            ans%=p;
        }
        md1=md;
    }
    a=0;
    b=0;
    c=0;
    md1=0;
    for(int i=n-1;i>-1;i--){
        if(s[i]=='R'){
            a++;
        }
        else if(s[i]=='G') b++;
        else c++;
        ll mn=min(a,min(b,c));
        ll mx=max(a,max(b,c));
        ll md=a+b+c-mn-mx;
        if(md>md1){
            ans*=(mx-md+1);
            ans%=p;
        }
        md1=md;
    }
    for(int i=0;i<n/3;i++){
        ans*=i+1;
        ans%=p;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 720
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}
int compl(const void *a, const void *b){return (*(long*)a>*(long*)b)-(*(long*)a<*(long*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int s[3];
int main(void){
	int n=nextpint();
	long ans=1;
	for(int i=0; i<n; i++){
		int a=nextpint();
		int b=(s[0]==a)+(s[1]==a)+(s[2]==a);
		ans=(ans*b)%P;
		if(0);
		else if(s[0]==a) s[0]++;
		else if(s[1]==a) s[1]++;
		else if(s[2]==a) s[2]++;
	}
	printf("%d\n", ans);
}


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

int main() {
  int a[10];
  int n;
  int x;

  a[0] = 1;
  for (int i=1; i<10; i++) {
    a[i] = a[i-1] << 1;
  }

  while (cin >> n) {
    for (int i=0; i<10; i++){
      x = n & 1;
      n >>=1;
      if (x) {
        if (n) {
          cout << a[i] << " ";
        } else {
          cout << a[i] << endl;
        }
      }
    }
  }
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }

int main()
{
	int N;
	vector<double> v;
	double tmp;

	cin >> N;
	rep(i, N)
	{
		cin >> tmp;
		v.push_back(tmp);
	}


	sort(v.begin(), v.end());
	tmp = v[0];

	for(int i = 1; i < N; i++)
		tmp = (tmp + v[i]) / 2;

	cout << tmp << endl;



	return 0;
}

Measured memory_bytes: 256
def main():
    a = int(input())
    ans = 0
    for i in range(a):
        b = input().split()
        if b[1] == 'JPY':
            ans += int(b[0])
        else:
            ans += float(b[0]) * 380000

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define br printf("\n")
int i,j;

int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll>v;
    while(m--)
    {
        ll x;
        cin>>x;
        v.push_back(x);
    }
    ll sum = accumulate(v.begin(),v.end(),0);
    if(sum>n)cout<<"-1"<<endl;
    else if(sum==n)cout<<"0"<<endl;
    else cout<<n-sum<<endl;


}


Measured memory_bytes: 3700
#include<iostream>
#include<queue>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
using namespace std;
int G[100][100];
queue<int> q;

class ANS
{
public:
	int id, d;
	bool done;
};

void bfs(ANS a[])
{
	q.push(a[0].id);
	a[q.front() - 1].done = true;
	a[q.front() - 1].d++;
	while (q.empty() != true)
	{
		int Q = q.front();
		FOR(i, 1, 101)
		{
			if (G[Q-1][i-1] == 1 && a[i-1].done == false)
			{
				a[i-1].done = true;
				a[i-1].d = a[Q-1].d + 1;
				q.push(i);
			}
		}
		q.pop();
	}
}

int main()
{
	ANS ans[100];
	int n;
	cin >> n;
	FOR(i, 0, n)
	{
		ans[i] = { i + 1,-1,false };
		int u, m;
		cin >> u >> m;
		FOR(j, 0, m)
		{
			int l;
			cin >> l;
			G[u - 1][l - 1] = 1;
		}
	}
	bfs(ans);
	FOR(i, 0, n)
	{
		cout << ans[i].id << " " << ans[i].d << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
typedef pair<int, P> E;
const ll MOD = 1e9 + 7;

vector<E> G[100000];
int in[100000];
vector<ll> euler;
vector<P> color[100000];
vector<ll> sum[100000];
vector<int> num[100000];
vector<ll> dist;
int parent[20][100000];
int depth[100000];
int N, Q;

void dfs(int v, int p, int d) {
	parent[0][v] = p;
	depth[v] = d;
	for (E e : G[v]) {
		if (e.first == p) continue;
		dfs(e.first, v, d + 1);
	}
}

void init(int root) {
	dfs(root, -1, 0);
	for (int k = 0; k + 1 < 20; k++) {
		for (int v = 0; v < N; v++) {
			if (parent[k][v] < 0) parent[k + 1][v] = -1;
			else parent[k + 1][v] = parent[k][parent[k][v]];
		}
	}
}

int lca(int u, int v) {
	if (depth[u] > depth[v]) swap(u, v);
	for (int k = 0; k < 20; k++) {
		if ((depth[v] - depth[u]) >> k & 1) {
			v = parent[k][v];
		}
	}
	if (u == v) return u;
	for (int k = 20 - 1; k >= 0; k--) {
		if (parent[k][u] != parent[k][v]) {
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}

void build(int v, int p) {
	for (E e : G[v]) {
		if (e.first == p) continue;
		if (in[e.first] == -1) in[e.first] = euler.size();
		color[e.second.first].emplace_back(euler.size(), e.second.second);
		euler.push_back(e.second.second);
		build(e.first, v);
		color[e.second.first].emplace_back(euler.size(), -e.second.second);
		euler.push_back(-e.second.second);
	}
}

ll calc_dist(int v) {
	if (v == 0) return 0;
	return dist[in[v]];
}

ll calc_sum(int v, int c) {
	if (v == 0) return 0;
	int idx = upper_bound(color[c].begin(), color[c].end(), P(in[v], 1LL << 60)) - color[c].begin();
	if (idx == 0) return 0;
	return sum[c][idx - 1];
}

ll calc_num(int v, int c) {
	if (v == 0) return 0;
	int idx = upper_bound(color[c].begin(), color[c].end(), P(in[v], 1LL << 60)) - color[c].begin();
	if (idx == 0) return 0;
	return num[c][idx - 1];
}

int main() {
	cin >> N >> Q;
	for (int i = 0; i < N - 1; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--; c--;
		G[a].emplace_back(b, P(c, d));
		G[b].emplace_back(a, P(c, d));
	}
	memset(in, -1, sizeof(in));
	init(0);
	build(0, -1);
	dist.resize(euler.size());
	dist[0] = euler[0];
	for (int i = 1; i < euler.size(); i++) dist[i] = dist[i - 1] + euler[i];
	for (int i = 0; i < N - 1; i++) {
		if (color[i].size() == 0) continue;
		sum[i].resize(color[i].size());
		sum[i][0] = color[i][0].second;
		for (int j = 1; j < color[i].size(); j++) sum[i][j] = sum[i][j - 1] + color[i][j].second;
		num[i].resize(color[i].size());
		num[i][0] = 1;
		for (int j = 1; j < color[i].size(); j++) {
			if (color[i][j].second >= 0) num[i][j] = num[i][j - 1] + 1;
			else num[i][j] = num[i][j - 1] - 1;
		}
	}
	for (int i = 0; i < Q; i++) {
		int x, y, u, v;
		cin >> x >> y >> u >> v;
		u--; v--; x--;
		int p = lca(u, v);
		ll A = calc_dist(u) + calc_dist(v) - 2 * calc_dist(p);
		ll B = calc_sum(u, x) + calc_sum(v, x) - 2 * calc_sum(p, x);
		ll C = calc_num(u, x) + calc_num(v, x) - 2 * calc_num(p, x);
		cout << A - B + C * y << endl;
	}
}

Measured memory_bytes: 42552
n,k=map(int,input().split())
a=list(map(int,input().split()))
hantei=10**10+1
for i in range(0,n-k+1):
  #print(a[i],a[i+k-1])
  d=a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1]))
  if hantei>d:
    hantei=d
print(hantei)

Measured memory_bytes: 14252
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  int a, b;
  std::string s;
  std::cin >> a >> b >> s;

  int i = 1;
  std::string d = {"1234567890"};
  for (auto &c : s) {
    if (i == (a + 1)) {
      if (c != '-') {
        std::cout << "No" << std::endl;
        return 0;
      }
    } else if (d.find(c) >= d.size()) {
      std::cout << "No" << std::endl;
      return 0;
    }
    ++i;
  }
  std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = [int(i) for i in input().split(maxsplit=N)]
    presum = [0 for _ in range(N + 1)]
    for i in range(N):
        presum[i + 1] = presum[i] + A[i]
    sumA = 0
    for i in range(1, N):
        sumA += (A[i] * (presum[i])) % (10**9 + 7)
    print(sumA % (10**9 + 7))


resolve()


Measured memory_bytes: 31384
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, NOW = 0;
	static pair<long long, long long> P[200000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i].second >> P[i].first;
	}
	sort(P, P + N);
	for (int i = 0; i < N; i++) {
		NOW += P[i].second;
		if (NOW > P[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[4009], pos[2][2019], cost[2][2019][2019], vis[2019];
char c[4009];
int dp[2019][2019];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= 2 * n; i++) {
		cin >> c[i] >> a[i];
		if (c[i] == 'W') pos[0][a[i]] = i;
		else pos[1][a[i]] = i;
	}
	for (int i = 1; i <= n; i++) {
		int ee = pos[0][i] - 1;

		memset(vis, 0, sizeof(vis));
		int cnt = 0;
		for (int j = 1; j <= ee; j++) {
			if (c[j] == 'W') {
				if (a[j] > i) cnt++;
			}
			else {
				vis[a[j]] = 1;
			}
		}
		for (int j = n - 1; j >= 1; j--) {
			vis[j] += vis[j + 1];
		}
		for (int j = 0; j <= n; j++) {
			cost[0][i][j] = cnt + vis[j + 1];
		}

	}
	for (int i = 1; i <= n; i++) {
		int ee = pos[1][i] - 1;

		memset(vis, 0, sizeof(vis));
		int cnt = 0;
		for (int j = 1; j <= ee; j++) {
			if (c[j] == 'B') {
				if (a[j] > i) cnt++;
			}
			else {
				vis[a[j]] = 1;
			}
		}
		for (int j = n - 1; j >= 1; j--) {
			vis[j] += vis[j + 1];
		}
		for (int j = 0; j <= n; j++) {
			cost[1][j][i] = cnt + vis[j + 1];
		}

	}
	for (int i = 1; i <= n; i++) {
		dp[0][i] = cost[1][0][i] + dp[0][i - 1];
	}
	for (int i = 1; i <= n; i++) {
		dp[i][0] = cost[0][i][0] + dp[i - 1][0];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = min(dp[i - 1][j] + cost[0][i][j], dp[i][j - 1] + cost[1][i][j]);
		}
	}
	cout << dp[n][n] << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 48000
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

def main():
    N = int(input())
    A = list(map(int, input().split()))
    max_A = max(A)
    ans = [0] * (max_A + 1)
    A.sort()
    for a in A:
        tmp = 1
        b = 0
        while b <= max_A:
            b = a * tmp
            if b > max_A:
                break
            ans[b] += 1
            tmp += 1
    cnt = 0
    for a in A:
        if ans[a] == 1:
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 94580
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N,count=0,ans=0,temp=-1;
  cin>>N;
  ll A[110000];
  for(int i=0;i<N;i++) cin>>A[i];
  sort(A,A+N);
  A[N]=-1;
  for(int i=0;i<=N;i++){
    if(temp!=A[i]){
      if(count%2) ans++;
      count=1;
      temp=A[i];
    }else count++;
  }
  cout<<ans<<endl;
}


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

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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if ((n & n - 1) == 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  for (int i = 2; i+1 <= n; i += 2) {
    cout << i << ' ' << i+1 << endl;
    cout << i+1 << ' ' << 1 << endl;
    cout << 1 << ' ' << i+n << endl;
    cout << i+n << ' ' << i+1+n << endl;
  }
  cout << 3+n << ' ' << 1+n << endl;
  if (n % 2 == 0) {
    cout << n << ' ' << n-1 << endl;
    cout << (n^(n-1)^1)+n << ' ' << n+n << endl;
  }
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(void){
  int n;
  ll T;
  cin >> n >> T;
  VI t(n);
  rep(i,n){
    cin >> t.at(i);
  }
  ll sum=0;
  for(int i=1;i<n;i++){
    if(t.at(i)-t.at(i-1)>=T){
      sum+=T;
    }
    else{
      sum+=(t.at(i)-t.at(i-1));
    }
  }
  cout << sum+T << endl;
   
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 大きい順に並び替える
    sort(res.rbegin(), res.rend());
    return res;
}
int main() {
	ll N, M;
	cin >> N >> M;

	const auto &res = enum_divisors(M);
	ll ans = 1;
	for (int ii = 0; ii < res.size(); ++ii){
		if (M / res[ii] >= N){
			ans = res[ii];
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

struct SegmentTree {
    int N;
    vector<int> dl, dr;
    
    SegmentTree(int N_)
    {
        N = 1;
        while (N < N_) {
            N *= 2;
        }
        
        dl.assign(2 * N - 1, -1);
        dr.assign(2 * N - 1, -1);
        
        for (int i = N - 1; i < 2 * N - 1; i++) {
            dl[i] = 0; dr[i] = 1;
        }
    }
    
    void eval(int k, int l, int r)
    {
        if (r == -1) {
            return;
        }
            
        if (dr[k] == -1) {
            dl[k] = l;
            dr[k] = r;
        } else if (dr[k] == l) {
            dr[k] = r;
        } else {
            dl[k] = dr[k] = -2;
        }
    }

    void update(int a, int b, int k, int l, int r, int x)
    {
        if (r <= a || b <= l) {
            return;
        }

        if (a <= l && r <= b) {
            eval(k, x, x + 1);
        } else {
            eval(k * 2 + 1, dl[k], dr[k]);
            eval(k * 2 + 2, dl[k], dr[k]);
            dl[k] = dr[k] = -1;
            update(a, b, k * 2 + 1, l, (l + r) / 2, x);
            update(a, b, k * 2 + 2, (l + r) / 2, r, x);
        }
    }

    void update(int l, int r, int x)
    {
        update(l, r + 1, 0, 0, N, x);
    }

    int query(int K)
    {
        for (int i = 0; i < N - 1; i++) {
            eval(i * 2 + 1, dl[i], dr[i]);
            eval(i * 2 + 2, dl[i], dr[i]);
        }
        
        int cnt = 0;
        for (int i = N - 1; i < 2 * N - 1; i++) {
            if (dl[i] == 0 && dr[i] == K + 1) {
                cnt += 1;
            }
        }
        return cnt;
    }
};

int main()
{
    int N, K, T;
    scanf("%d %d %d", &N, &K, &T);    
    
    SegmentTree seg(N);
    for (int i = 0; i < T; i++) {
        int l, r, x;
        scanf("%d %d %d", &l, &r, &x);
        seg.update(l - 1, r - 1, x);
    }
        
    printf("%d\n", seg.query(K));
    return 0;
}

Measured memory_bytes: 6320
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(int &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;

int main() {
	int n = in();
	v h(n);
	for (int &x: h)
		x = in();

	for (int i = 1, p, l, r; i <= n; i++) {
		p = i / 2, l = 2 * i, r = 2 * i + 1;
		out("node ", i, ": key = ", h[i - 1], ", ");
		if (p)
			out("parent key = ", h[p - 1], ", ");
		if (l <= n)
			out("left key = ", h[l - 1], ", ");
		if (r <= n)
			out("right key = ", h[r - 1], ", ");
		out('\n');
	}
}



Measured memory_bytes: 2536
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aps
 */

#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

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

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

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

const int N = 55;
typedef vector<vi> matrix;

int d[N][N],n,k;

class RWalk {
public:
    matrix mul_mat(matrix a, matrix b){
        matrix c(n,vi (n,0));
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                for(int kk=0;kk<n;kk++){
                    c[i][j] = add(c[i][j],mul(a[i][kk],b[kk][j]));
                }
            }
        }
        return c;
    }

    matrix power_mat(matrix mat,int expo){
        if(expo == 1) return mat;
        if(expo&1) return mul_mat(mat,power_mat(mat,expo-1));
        matrix x = power_mat(mat,expo/2);
        return mul_mat(x,x);
    }

    void solve(std::istream& cin, std::ostream& cout){
        cin >> n >> k;
        matrix T(n,vi (n,0));
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++) cin >> T[i][j];
        }
        T = power_mat(T,k);
        int ans=0;
        for(int i=0;i<n;i++) for(int j=0;j<n;j++) ans = add(ans,T[i][j]);
        cout << ans << endl;
    }
};


int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    RWalk solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;
const int MAX = 600;

vector<int> G[MAX];
long double fdp[MAX];
int n;

long double solve(int f, int s) {
  vector<long double> dp(n - 1, 0.0);
  repr(u, n - 2) {
    long double sum = (long double)G[u].size();
    if (u == f) sum -= 1.0;
    long double exp = sum;
    for (int v: G[u]) {
      if (u == f && v == s) continue;
      if (dp[v] > 0) exp += dp[v];
    }
    dp[u] = exp / sum;
  }

  if (f == -1 && s == -1) {
    repr(u, n - 2) fdp[u] = dp[u];
  }

  return dp[0];
}

int main() {
  int m;
  cin >> n >> m;
  int s, t;
  rep(i, m) {
    cin >> s >> t;
    G[s - 1].push_back(t - 1);
  }

  long double ans = solve(-1, -1);
  repr(u, n - 2) {
    if (G[u].size() == 1) continue;
    int maxv = G[u][0];
    for (int v: G[u]) {
      if (fdp[v] > fdp[maxv]) {
        maxv = v;
      }
    }
    ans = min(ans, solve(u, maxv));
  }
  cout << setprecision(10) << ans << endl;

  
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
string S,S_org,T;
void rotate(string*s){
  const string init=s->substr(0,s->size()-1);
  const string last=s->substr(s->size()-1,1);
  *s=last+init;
}
main(){
  cin>>S>>T;
  S_org=S;
  bool found=false;
  do{
    // cout<<S<<endl;
    if(S==T){
      found=true;
    }
    rotate(&S);
  }while(S!=S_org);
  cout<<(found?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n;
int A[20];
bool flag=false;
void dfs(int u,int sum,int key)
{
    //if(flag)return;
    if(sum==key)
    {
        flag=true;
        return;
    }
    if(u==n){
        return;
    }
    dfs(u+1,sum,key);
    dfs(u+1,sum+A[u],key);
}
int main()
{
    int q,M[200];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>A[i];
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>M[i];
        dfs(0,0,M[i]);
        if(flag)
            cout<<"yes"<<endl;
        else
            cout<<"no"<<endl;
        flag=false;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
using namespace std;
using namespace __gnu_pbds;
bool comp(pair<ll,ll> a,pair<ll,ll> b) {       }
const ll MOD=1e9+7;
void print(vector<vector<ll> >&v)
{
    ll n=v.size();
    ll m=v[0].size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
void print(vector<ll>&v)
{
    ll n=v.size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
            cout<<v[i]<<" ";
    }
        cout<<"\n";

}
void print(set<ll>&s)
{

cout<<endl;

set<ll>::iterator it;
for(it=s.begin();it!=s.end();it++)
    cout<<*it<<" ";
cout<<endl;
}
ll __lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
ll power(ll a,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1){
            res=(res*a)%MOD;
            p--;
        }
            a=(a*a)%MOD;
            p/=2;
    }

    return res%MOD;
}
const ll INF=1e16;
const ll nxm=2e5+5;

ll spf[nxm];
void sieve()
{
    memset(spf,-1,sizeof(spf));

    spf[0]=spf[1]=1;

    for(ll i=2;i<nxm;i++)
    {
        if(spf[i]==-1)
            spf[i]=i;
        for(ll j=i*i;j<nxm;j+=i)
        {
            if(spf[j]==-1)
                spf[j]=i;

        }

    }
//    while(x>1)
//    {
//        ll s=spf[x];
//        temp[s]++;
//        x/=s;
//    }


// log n prime factor
}
void solve(){



    ll n,k;

    cin>>n>>k;


    ll ans=0;

    REP(i,0,n)
    {
        ll x,y;

        cin>>x>>y;

        ll val=x*x+y*y;

        if(k*k>=val)
        {
            ans++;
        }

    }
    cout<<ans;



















}
int main(){
//    freopen("timber_input", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<": ";
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;
/*

char s[100];

fgets(s,100,stdin);

stringstream stram(s);

string abc;

bool ok1=0,ok2=0;

while(stram>>abc)
*/


Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n, h, min_val = 0, ans = 0;
	cin >> n;
	rep(i, 0, n) {
		cin >> h;
		if (min_val <= h) {
			ans++;
			min_val = h;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int main(void){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    vector<int> Y;
    Y = X;
    sort(Y.begin(), Y.end());
    int mini = Y[N/2-1];
    int maxi = Y[N/2];
    for(int i = 0; i < N; i++){
        if(X[i] < mini){
            cout << maxi << endl;
        }else if(X[i] > maxi){
            cout << mini << endl;
        }else if(X[i] == mini){
            cout << maxi << endl;
        }else{
            cout << mini << endl;
        }
    }
    
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long long n,m,sum=0;
     cin>>n>>m;
     long long arr[m];
     for(int i=0;i<m;i++)
     {
          cin>>arr[i];
          sum=sum+arr[i];

     }
     if(sum>n)
          cout<<-1;
     else
          cout<<n-sum;
     return 0;

}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int>dp(W + 1, 0);
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	rep(i, 0, N)rrep(j, w[i], W + 1)chmax(dp[j], dp[j - w[i]] + v[i]);
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int x, n, vis[200], ans, mx=1e9;
int main()
{
    IO
    cin>>x>>n;
    for(int i=1; i<=n; i++)
    {
        int y ;
        cin>>y;
        vis[y]++;
    }
    for(int i=0; i<=300; i++)
    {
        if(vis[i])
            continue;
        if(abs(i-x)<mx)
            mx=abs(i-x), ans=i;
    }
    cout<<ans;
}


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


int main(){
    int N;
    cin >> N;
    vector<vector<pair<int,int>>> A(N);
    for(int i=0;i<N;i++){
        int num;
        cin >> num;
        for(int j=0;j<num;j++){
            int x, y;
            cin >> x >> y;
            x--;
            A[i].push_back(make_pair(x,y));
        }
    }
    int ans=0;
    for(int tmp;tmp<(1<<N);tmp++){
        bool ans2=true;
        int cnt=0;
        bitset<15> s(tmp);
        for(int i=0;i<N;i++){
            if(s.test(i)){
                for(int j=0;j<A[i].size();j++){
                    int x,y;
                    tie(x,y)=A[i][j];
                    if(y==1 && !s.test(x)){
                        ans2=false;
                        break;
                    }
                    else if(y==0 && s.test(x)){
                        ans2=false;
                        break;
                    }
                }
                cnt++;
            }
            if(!ans2) break;
        }
        if(ans2) ans=max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

class UnionFind:
    # 初期化
    def __init__(self, n):
        # 根なら-size, 子なら親の頂点
        self.par = [-1] * n
        # 木の高さ
        self.rank = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 異なる集合に属する場合のみ併合
        if x != y:
            # 高い方をxとする。
            if self.rank[x] < self.rank[y]:
                x,y = y,x
            # 同じ高さの時は高さ+1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            # yの親をxとし、xのサイズにyのサイズを加える
            self.par[x] += self.par[y]
            self.par[y] = x

    # 同集合判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 集合の大きさ
    def size(self, x):
        return -self.par[self.find(x)]


n,m = readints()
u = UnionFind(n)
for i in range(m):
    a,b = (x-1 for x in readints())
    u.unite(a,b)

print(max([u.size(x) for x in range(n)]))




Measured memory_bytes: 94912
N = int(input())
a = list(map(int, input().split()))

S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + a[i]

dp = [[float('inf') for _ in range(N)] for _ in range(N)]
for i in range(N):
    dp[i][i] = 0
for i in range(N-1):
    dp[i][i+1] = a[i] + a[i+1]
for d in range(2, N):
    for i in range(N - d):
        for k in range(d):
            dp[i][i+d] = min(dp[i][i+d], S[i+d+1] - S[i] + dp[i][i+k] + dp[i+k+1][i+d])

print(dp[0][N-1])


Measured memory_bytes: 48604
#include <bits/stdc++.h>
#define reg register
using namespace std;
const int MAXN = 2e5 + 10;
int n, m;
double f[MAXN], sum[MAXN];
int main() {
    scanf("%d%d", &n, &m);
    for(reg int i = 1; i <= n; ++i) {
        scanf("%lf", &f[i]);
        sum[i] = sum[i - 1] + (f[i] + 1) / 2;
    }
    double ans = 0;
    for(reg int i = 1; i <= n - m + 1; ++i)
        ans = max(ans, sum[i + m - 1] - sum[i - 1]);
    printf("%.8f\n", ans);
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if(m<n)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    dp = [False] * (K+1)

    for i in range(0,K+1):
        for a in A:
            if i - a >= 0:
                # 遷移先に一つでもFalseがあれば遷移元dp[i]を勝ち(True)にできる
                # 遷移先が全てTrueであれば、勝つことはできないので遷移元dp[i]はFalseになる
                dp[i] = dp[i] or (not dp[i-a])

    if dp[K]:
        print('First')
    else:
        print('Second')




if __name__ == '__main__':
    main()


Measured memory_bytes: 9612
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t=1;
    // cin>>t;
    while(t--){
        ll a,b,c;
        cin>>a>>b>>c;
        ll k;
        cin>>k;
        while(k && b<=a){
            b*=2;
            k--;
        }
        while(k && c<=b){
            c*=2;
            k--;
        }
        if(a<b && b<c){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;

}


Measured memory_bytes: 3684
// Last Change: 05/26/2019 21:41:55.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int N, M;
vector<vector<int>> lightInfo;
vector<int> p;

ll DFS(ll turn, int depth) {
  if (depth == N) {
    turn = turn << 1;

    for (int i = 0; i < M; ++i) {
      int cnt = 0;
      for (auto &&e : lightInfo[i]) {
        if ((turn & (1 << e))) {
          ++cnt;
        }
      }
      if (cnt % 2 != p[i]) {
        return 0;
      }
    }

    return 1;
  }

  return DFS((turn << 1) | 1, depth + 1) + DFS((turn << 1), depth + 1);
}

int main() {
  cin >> N >> M;
  lightInfo.resize(M);
  p.resize(M);

  int k, s;
  for (int i = 0; i < M; ++i) {
    cin >> k;
    for (int j = 0; j < k; ++j) {
      cin >> s;
      lightInfo[i].push_back(s);
    }
  }
  for (auto &&e : p) {
    cin >> e;
  }

  ll ans = DFS(0, 0);
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> v(N);
    for (auto& i : v) cin >> i;
    sort(v.begin(), v.end());
    for (auto i : v) cout << i; cout << endl;

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  130-B Bounding
//
//  Created by 李罗罗 on 2019/8/24.
//  Copyright © 2019 李罗罗. All rights reserved.
//

#include <iostream>
#include <cmath>
#define maxn 105
using namespace std;

int n,x;
int L[maxn],S[maxn];
int flag=1<<30,ans=1;
int main(int argc, const char * argv[]) {
    cin>>n>>x;
    S[1]=0;
    for(int i=1;i<=n;i++){
        cin>>L[i];
        S[i+1]=S[i]+L[i];
    }
    
    for(int i=1;i<=n+1;i++){
        if(x>=S[i]&&x-S[i]<flag){
            flag=abs(S[i]-x);
            ans=i;
        }
    }
    cout<<ans;
    return 0;
}


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

int main(){
    double a,b,h,w;
    cin >> a >> b >> h >> w;
    
    
    double degA = (60*h+w)/(60*12)*M_PI*2;
    double degB = (60*h+w)/(60)*M_PI*2;
    double diff = min(abs(degA-degB), abs(M_PI*2-abs(degA-degB)));
    
    double c = a*a+b*b-2*a*b*cos(diff);
    
    double ans = sqrt(c);
    printf("%.15f", ans);
}

Measured memory_bytes: 4228
n,c,k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
now = t[0]
people = 1
ans = 1
for i in t[1:]:
  if i - now > k or people >= c:
    now = i
    people = 1
    ans += 1
  else:
    people += 1
print(ans)


Measured memory_bytes: 7888
#include <iostream>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;cin>>n;
    int count=0;
  	for(int i=1;i<n-1;i++){
      if(n-i != i){
        count++;
      }
    }
    if(count%2==0){
        count=count/2;
    }
    else{
        count=(count+1)/2;
    }
    cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 888
import java.util.*;
public class Main{
	static String CardGame(String[] s){
		int len = 0;
		for(int i=0; i<3; i++){
			len += s[i].length();
		}
		int turn = 0;
		int next = 0;
		for(int i=0; i<len; i++){
			if(s[turn].length()==0){
				if(turn==0){
					return "A";
				}
				else if(turn==1){
					return "B";
				}
				else {
					return "C";
				}
			}

			else {
				if(s[turn].charAt(0)=='a'){
					next=0;
				}
				else if(s[turn].charAt(0)=='b'){
					next=1;
				}
				else {
					next=2;
				}
				s[turn] = s[turn].substring(1);
				turn = next;
			}
		}
		return "";
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] S = new String[3];
		for(int i=0; i<3; i++){
			S[i] = sc.next();
		}
		System.out.println(CardGame(S));
	}
}

Measured memory_bytes: 23380
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[22000];

int main(){
	int H, N;
	cin >> H >> N;
	DP[0] = 0;
	for(int i = 1; i < 22000; i++){
		DP[i] = INF;
	}
	for(int i = 0; i < N; i++){
		long long int A, B;
		cin >> A >> B;
		for(int j = A; j < 22000; j++){
			DP[j] = min(DP[j], DP[j - A] + B);
		}
	}
	long long int ans = INF;
	for(int i = H; i < 22000; i++){
		ans = min(ans, DP[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
int main()
{
	int d,n;cin>>d>>n;
	if(n==100)n++;
	cout<<n;
	if(d==1)cout<<"00"<<endl;
	if(d==2)cout<<"0000"<<endl;
	return 0;
}

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

import sys

outList = []
for line in sys.stdin.readlines():
    List = map(float, line.strip().split())

    [a, b, c, d, e, f] = List

    x = (b*f-c*e)/(b*d-a*e)
    y = (a*f-c*d)/(a*e-b*d)

    outList.append("%.3f %.3f" % (x+0, y+0))

for i in xrange(len(outList)):
    print outList[i]

Measured memory_bytes: 4236
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#include<sstream>
using namespace std;
int main()
{
	float a,b;
	int i;
	cin>>a>>b;
	int ans=0;
	for(i=1;i<=1500;i++)
	{
		if(floor(i*0.08)==a&&floor(i*0.1)==b)
		{
			ans=i;
			break;
		}
	}
	if(ans==0)
	{
		cout<<"-1";
	}
	else
	{
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    if(n >= 195){
        ans = 5;
    }else if(n >= 189){
        ans = 4;
    }else if(n >= 165){
        ans = 3;
    }else if(n >= 135){
        ans = 2;
    }else if(n >= 105){
        ans = 1;
    }else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

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

int main () {
  int c[3][3];
  int b[3][2];
  int a[2][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
      if (j != 0) {
        b[i][j - 1] = c[i][j] - c[i][j - 1];  
      }  
      if (i != 0) {
        a[i - 1][j] = c[i][j] - c[i - 1][j];  
      }
    }  
  }  

  for (int i = 0; i < 2; i++) {
    if (a[i][0] == a[i][1] &&
        a[i][1] == a[i][2]) {
        
    } 
    else {
      cout << "No" << endl;
      return 0;  
    } 
  }
  for (int i = 0; i < 2; i++) {
    if (b[0][i] == b[1][i] &&
        b[0][i] == b[2][i]) {
        
    } 
    else {
      cout << "No" << endl;  
    } 
  }
  cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int a[10001],n,i,k;
    int *b;
    for(i=0;i<10001;i++){
        a[i]=0;
    }
    scanf("%d",&n);
    b = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        scanf("%d",&k);
        a[k]++;
    }
    k=0;
    for(i=0;i<10001;){
        if(a[i]==0){
            i++;
        }else{
            b[k] = i;
            a[i]--;
            k++;
        }
    }
    for(i=0;i<n;i++){
        printf("%d",b[i]);
        if(i!=n-1){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 9580
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 405
#define maxm 100010
#define inf 999999999999999
#define mod 998244353
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,sa,sb;
int a[maxn],b[maxn];
int f[maxn][maxn][maxn];
int fac[maxn],inv[maxn];
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
void add(int &x,int y)
{
    x=(x+y>=mod)?(x+y-mod):x+y;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  a[i]=read(),b[i]=read(),sa+=a[i],sb+=b[i];
    fac[0]=1;for(int i=1;i<=400;i++)  fac[i]=1ll*fac[i-1]*i%mod;
    inv[400]=quick_pow(fac[400],mod-2);
    for(int i=399;i>=0;i--)  inv[i]=1ll*inv[i+1]*(i+1)%mod;
    f[0][0][0]=mod-1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=sa;j++)
        {
            for(int k=0;k<=sb;k++)
            {
                if(!f[i-1][j][k])  continue;
                add(f[i][j][k],f[i-1][j][k]);
                int x=1;
                for(int l=0;l<b[i];l++,x=1ll*x*a[i]%mod) add(f[i][j+a[i]][k+l],mod-1ll*x*inv[l]%mod*f[i-1][j][k]%mod);
            }
        }
    }
    int ans=0;
    for(int i=1;i<=sa;i++)
    {
        int y=quick_pow(i,mod-2);
        int x=1ll*sa*y%mod;
        for(int j=0;j<=sb;j++,x=1ll*x*y%mod)  add(ans,1ll*x*fac[j]%mod*f[n][i][j]%mod);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256256
N = int(input())
A = list(map(int, input().split()))

count = 1
state = ""
for i in range(N-1):
    if A[i] > A[i+1] and state == "":
        state = "minus"
    elif A[i] > A[i+1] and state == "plus":
        state = ""
        count += 1
    elif A[i] > A[i+1] and state == "minus":
        continue
    elif A[i] < A[i+1] and state == "":
        state = "plus"
    elif A[i] < A[i+1] and state == "minus":
        state = ""
        count += 1
    elif A[i] < A[i+1] and state == "plus":
        continue
    else:
        continue
print(count)

Measured memory_bytes: 14484