akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N; cin >> N;
    vector<Pi> P(N);
    rep(i,N){
        cin >> P[i].first;
        P[i].second = i;
    }
    sort(P.begin(),P.end(),greater<Pi>());
    multiset<int> s;
    s.insert(-1);
    s.insert(-1);
    s.insert(N);
    s.insert(N);
    ll ans = 0;
    rep(i,N){
        if(i == 0) s.insert(P[i].second);
        else{
            auto itr = s.lower_bound(P[i].second);
            int r1 = *itr;
            itr++;
            int r2 = *itr;
            itr--;
          	itr--;
            int l1 = *itr;
            itr--;
            int l2 = *itr;
            //cout << r1 << " " << r2 << " " << l1 << " " << l2 << endl;
            ans += ((ll)(l1-l2)*(r1-P[i].second)+(ll)(P[i].second-l1)*(r2-r1))*P[i].first;
            //cout << ans << endl;
            s.insert(P[i].second);
        }
    }
    cout << ans << endl;

}
   


Measured memory_bytes: 5760
#include <iostream>
#include <list>
#include <algorithm>
int main() {
    int n;
    std::cin >> n;
    std::list<int> ls;
    std::string op;
    int x;
    while (n-- > 0) {
        std::cin >> op;
        if (op == "insert") {
            std::cin >> x;
            ls.push_front(x);
        } else if (op == "delete") {
            std::cin >> x;
            auto i = std::find(ls.begin(), ls.end(), x);
            if (i != ls.end()) {
                ls.erase(i);
            }
        } else if (op == "deleteFirst") {
            ls.pop_front();
        } else {
            ls.pop_back();
        }
    }
    for (auto i = ls.begin(); i != ls.end(); ++i) {
        std::cout << ((i == ls.begin()) ? "" : " ") << *i;
    }
    std::cout << std::endl;
}



Measured memory_bytes: 34416
def main():
    """
    1 <= N <= 2 * 10^5
    0 <= Ai <= 2^20

    1 <= l <= r <= N

       Al xor Al_1 xor ... xor Ar
    == Al  +  Al_1  +  ... xor Ar
    """
    N = int(input())
    *A, = map(int, input().split())

    editorial(N, A)


def editorial(N, A):
    """
    a + b − (a xor b) = 2 × (a and b)
    （ただしここで andはビットごとの論理積を表す）
    とは？

    xy|xor|(x xor y) xor y
    00|  0|0
    01|  1|0
    10|  1|1
    11|  0|1

    計算量を減らすための工夫
    しゃくとり法
    累積和, 累積XOR
    """
    ans = shakutori(N, A)
    #ans = bin_search_TLE(N, A)
    print(ans)


def bin_search_TLE(N, A):
    N_BIT = 20
    b = [
        [0] * (N+1)
        for _ in range(N_BIT)
    ]
    # bitごとの累積和
    for j in range(N_BIT):
        for i in range(N):
            x = (A[i] >> j) & 1
            b[j][i+1] = x + b[j][i]

    import bisect
    ans = 0
    for i in range(N):
        tmp = float("inf")
        for j in range(N_BIT):
            # 累積和の調整
            # i=1のとき i=0まで累積和+1がi=1以降では許容される
            a = 1 + b[j][i]
            x = bisect.bisect_right(b[j][i:], a)
            # 0 to N-1ではなく、0 to Nなので -1
            tmp = min(tmp, x - 1)
        #print("i:", i, "tmp:", tmp, "x:", x, "a:", a, "b[j][i]:", b[j][i], sep="\t")
        ans += tmp

    return ans

    for x in b:
        print(*x)


def shakutori(N, A):
    """しゃくとり法
    """
    ans = 0
    right = 0
    _sum = 0
    for left in range(N):
        # 右の限界判定, rightを進めたときの条件判定
        while right < N and (_sum ^ A[right]) == (_sum + A[right]):
            # 進めたときの状態変化
            _sum += A[right]
            right += 1

        # 条件を満たす範囲
        ans += right - left

        if left == right:
            # 詰まっているので、条件判定前に戻す必要なし
            right += 1
        else:
            # 右を右へずらさず左を右へずらすので、条件判定前に戻す
            _sum -= A[left]

    return ans


def f(N, A):
    """
    入力例1

    (1,r)=(1,2) => [2,5]
    2: 010
    5: 101
    ------
    7: 111

    XOR: 0が1or偶数個,1が1つ? すべてのbitが立つ?
    """
    pass


def TLE(N, A):
    ans = 0
    for i in range(N):
        for j in range(i+1, N+1):
            a1 = A[i:j]
            s = sum(a1)

            x = a1[0]
            for y in a1[1:]:
                x ^= y
            if x == s:
                ans += 1
            print((i, j), x, s, ans, a1, sep="\t")

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24836
#include<stdio.h>
int main(void)
{
	int b1,b2,b3;
	scanf("%d",&b1);
	scanf("%d",&b2);
	scanf("%d",&b3);
	if(b1==1 && b2==0 && b3==0){
		printf("Close\n");
	}
	if(b1==0 && b2==1 && b3==0){
		printf("Close\n");
	}
	if(b1==1 && b2==1 && b3==0){
		printf("Open\n");
	}
	if(b1==0 && b2==0 && b3==1){
		printf("Open\n");
	}
	if(b1==0 && b2==0 && b3==0){
		printf("Close\n");
	}
	return 0;
}


Measured memory_bytes: 2144
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int ans = min(n, k) * x + max(n - k, 0) * y;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

bool flag[100010];
ll sum[100010];

bool isPrime(int x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}

int main(){
    int q;
    cin >> q;
    int l, r;
    ll cnt = 0;
    REP(i, 100010){
        if(isPrime(i) && isPrime((i+1)/2)){
            flag[i] = true;
            cnt++;
        }
        sum[i] = cnt;
    }
    rep(i, q){
        cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n;
map<string,int> mp;
bool cmp(pair<int,string> a,pair<int,string> b)
{
	if(a.first!=b.first) return a.first>b.first;
	return a.second<b.second;
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	vector<pair<int,string> > vec;
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
		vec.push_back(make_pair(it->second,it->first));
	sort(vec.begin(),vec.end(),cmp);
	for(int i=0;i<vec.size();i++)
		if(vec[i].first==vec[0].first)
			cout<<vec[i].second<<endl;
	return 0;
}


Measured memory_bytes: 28144
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int n;
int a[101];
vector<int> G[101];
int cnt[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	if(n==2)printf("Possible\n");
	else{
		sort(a,a+n);
		bool flag=true;
		if(a[1]==1)flag=false;
		for(int i=0;i<n;i++){
			cnt[a[i]]++;
		}
		if(cnt[a[0]]>2)flag=false;
		if(cnt[a[0]]==1){
			if(a[0]*2!=a[n-1])flag=false;
			for(int i=a[0]+1;i<=a[n-1];i++){
				if(cnt[i]<2)flag=false;
			}
		}else{
			if(a[0]*2-1!=a[n-1])flag=false;
			for(int i=a[0]+1;i<=a[n-1];i++){
				if(cnt[i]<2)flag=false;
			}
		}
		printf("%s\n",flag?"Possible":"Impossible");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

//suppose that every capacity is in the domaion of integer.
public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	@SuppressWarnings("unchecked")
	void solver() {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		ArrayList<Edge>[] g = new ArrayList[V];
		for (int i = 0; i < V; i++) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < E; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int c = sc.nextInt();
			g[u].add(new Edge(u, v, c));
		}
		Preflow_Relabel pr = new Preflow_Relabel(0, V - 1, g);
		System.out.println(pr.calc());
	}

	class Preflow_Relabel {
		int n;
		int s;
		int t;
		ArrayList<Edge>[] g;
		int[][] flow;
		int[][] capacity;
		int[] excess;
		int[] height;
		PriorityQueue<Vertice> que = new PriorityQueue<>();

		public Preflow_Relabel(int s, int t, ArrayList<Edge>[] g) {
			this.g = g;
			this.s = s;
			this.t = t;
			n = g.length;
			flow = new int[n][n];
			capacity = new int[n][n];
			height = new int[n];
			height[s] = n;
			excess = new int[n];

			for (int i = 0; i < n; i++) {
				for (Edge e : g[i]) {
					if (e.weight > 0) {
						g[e.dst].add(new Edge(e.dst, e.src, 0));
						capacity[e.src][e.dst] += e.weight;
					} else if (e.weight == 0) {
						continue;
					}
				}
			}
		}

		int calc() {
			for (Edge e : g[s]) {
				excess[s] += e.weight;
				push(s, e.dst);
			}
			while (!que.isEmpty()) {
				Vertice v = que.poll();
				if (excess[v.id] == 0 || v.id == t || height[v.id] != v.height) {
					continue;
				}
				for (Edge e : g[v.id]) {
					if (height[e.src] == height[e.dst] + 1) {
						if (residue(e.src, e.dst) > 0) {
							push(e.src, e.dst);
							if (excess[v.id] == 0)
								break;
						}
					}
				}
				if (excess[v.id] > 0) {
					int min = 1 << 30;
					for (Edge e : g[v.id]) {
						if (residue(e.src, e.dst) > 0) {
							min = Math.min(min, height[e.dst]);
						}
					}
					height[v.id] = min + 1;
					que.add(new Vertice(v.id, height[v.id]));
				}
			}
			return excess[t];
		}

		int residue(int s, int t) {
			return capacity[s][t] - flow[s][t];
		}

		void push(int u, int v) {
			int delta = Math.min(excess[u], residue(u, v));
			flow[u][v] += delta;
			flow[v][u] -= delta;
			excess[v] += delta;
			excess[u] -= delta;
			if (v != t && v != s) {
				que.add(new Vertice(v, height[v]));
			}
		}

		class Vertice implements Comparable<Vertice> {
			int id;
			int height;

			public Vertice(int id, int height) {
				this.id = id;
				this.height = height;
			}

			@Override
			public int compareTo(Vertice o) {
				return -Integer.compare(this.height, o.height);
			}
		}
	}

	class Edge {
		int src;
		int dst;
		int weight;

		Edge(int src, int dst, int weight) {
			this.src = src;
			this.dst = dst;
			this.weight = weight;
		}
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 37552
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double

using namespace std;

int main()
{
	fio
	ll N,H;
	cin>>H>>N;
	ll sum=0,temp;
	f(i,0,N)
	{
		cin>>temp;
		sum+=temp;
	}
	sum>=H?cout<<"Yes\n":cout<<"No\n";
	return 0;
}


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

ans=[]
for i in range(n):
    for j in range(len(b)-1, -1, -1):
        if b[j]==j+1:
            ans.append(b.pop(j))
            break
ans=list(reversed(ans))

if len(ans)!=n:
    print(-1)
else:
    for ans_i in ans:
        print(ans_i)



Measured memory_bytes: 9024
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
	int a[10], num;
	int count = 0;

	while(cin >> num){
		if(num != 0){
			a[count] = num;
			count++;
		}
		else{
			cout << a[count - 1] << endl;
			count--;
		}
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string P, W, G, Y;
   int x = 3;

  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    if( S == "Y" ){
      x ++;
    }
    
    else{
      continue;
    }
  }
  
  if(x == 3){
    cout << "Three" <<endl;
  }
  else{
    cout << "Four" << endl;
  }
  
  }
  
      
    

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

struct DPItem
{
  uint64_t money, stock, price;
  DPItem(uint64_t money, uint64_t stock, uint64_t price)
    : money(money), stock(stock), price(price) {}
  uint64_t operator()() const {
    return money + stock * price;
  }
  bool operator<(const DPItem &rhs) const {
    return (*this)() < rhs();
  }
  bool operator>(const DPItem &rhs) const {
    return (*this)() > rhs();
  }
};

const uint64_t M = 1e+5;

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

  vector<uint64_t> A(N);
  cin >> A;

  vector<maximum_heap<DPItem>> dp(N + 1);
  dp[0].emplace(1000, 0, 0);
  N_TIMES(n, N) {
    uint64_t cnt = 0;
    while (!dp[n].empty() && cnt < M) {
      DPItem item = dp[n].top(); dp[n].pop();
      // 何もしない
      dp[n + 1].push(item);
      ++cnt;

      // 全株売却
      if (item.stock > 0 && item.price < A[n]) {
        if ((n == N - 1) || (n < N - 1 && A[n] > A[n + 1])) {
          dp[n + 1].emplace(item.money + item.stock * A[n], 0, 0);
          ++cnt;
        }
      }

      // 最大購入
      uint64_t c = item.money / A[n];
      if (item.stock == 0 && c > 0) {
        if ((n == N - 1) || (n < N - 1 && A[n] < A[n + 1])) {
          dp[n + 1].emplace(item.money % A[n], item.stock + c, A[n]);
          ++cnt;
        }
      }
    }
  }

  uint64_t max_money = 0;
  while (!dp[N].empty()) {
    DPItem item = dp[N].top(); dp[N].pop();
    max_money = max(max_money, item());
  }
  cout << max_money << endl;

  return 0;
}

Measured memory_bytes: 143604
def main():
    n = int(input())
    dp = [0 for _ in range(n + 1)]
    for i in range(n):
        p = int(input())
        dp[p] = dp[p - 1] + 1
    non_move = 0
    for i in range(n + 1):
        non_move = max(non_move, dp[i])
    print(n - non_move)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16720
import sys
sys.setrecursionlimit(500000)

N = int(input())
T = [[i] + list(map(int, input().split())) for i in range(N)]
E = [[] for i in range(N)]
E = []
T.sort(key=lambda x: x[1])
for i in range(N-1):
    s, l = T[i:i+2]
    E.append([s[0], l[0], l[1]-s[1]])
T.sort(key=lambda x: x[2])
for i in range(N-1):
    s, l = T[i:i+2]
    E.append([s[0], l[0], l[2]-s[2]])
E.sort(key=lambda x: x[2])

Par = list(range(N))
def root(x):
    if Par[x] == x:
        return x
    else:
        Par[x] = root(Par[x])
        return Par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        Par[x] = y

ans = 0
for e in E:
    if not same(e[0], e[1]):
        ans += e[2]
        unite(e[0], e[1])

print(ans)


Measured memory_bytes: 127956
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

using ld = double;
using P = complex<ld>;

const ld eps = 1e-11;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }


template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v(n);
    for (int i = 0; i < n; ++i) {
        double x, y;
        cin >> x >> y;
        v[i] = { x, y };
    }
    cout << setprecision(14) << sqrt(min_ball(v.begin(), v.end()).second) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

int main(){
  int K;
  std::cin >> K;
  std::vector<std::vector<int>> X = {{1},{2},{3},{4},{5},{6},{7},{8},{9}};
  std::vector<std::vector<int>> Y;
  while(true){
    if(K <= X.size()){
      long num = 0;
      std::vector<int> ans(X[K-1]);
      for(const auto& e: ans){
        std::cout << e;
      }
      std::cout << std::endl;
      return 0;
    }
    for(int i = 0; i < X.size(); ++i){
      int X_last = X[i].back();
      if(X_last == 0){
        std::vector<int> c1(X[i]);
        std::vector<int> c2(X[i]);
        c1.push_back(0);
        c2.push_back(1);
        Y.push_back(c1);
        Y.push_back(c2);
      }
      else if(X_last == 9){
        std::vector<int> c1(X[i]);
        std::vector<int> c2(X[i]);
        c1.push_back(8);
        c2.push_back(9);
        Y.push_back(c1);
        Y.push_back(c2);
      }
      else{
        std::vector<int> c1(X[i]);
        std::vector<int> c2(X[i]);
        std::vector<int> c3(X[i]);
        c1.push_back(X_last-1);
        c2.push_back(X_last);
        c3.push_back(X_last+1);
        Y.push_back(c1);
        Y.push_back(c2);
        Y.push_back(c3);
      }
    }
    K -= X.size();
    X = std::move(Y);
  }
  return 0;
}

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

    int main (){
        int a,b;
        cin >> a >> b;
        int n=b-a;
        int cunt=0;
        for(int i=a;i<=b;i++){
          int s= i%10,t=i/10000%10;
          int u= i/10%10,v=i/1000%10;
          if(s==t&&u==v)cunt++;
          
        }
        cout << cunt << endl;
        return 0;
    }


Measured memory_bytes: 3600
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n,m = map(int,input().split())
  OK = [0] * m + [0]
  cnt = 0
  while True:
    try:
      LIST = list(map(int,input().split()))
      k = LIST[0]
      A = LIST[1:]
      for i in range(k):
        OK[A[i]] += 1
    except:
      break
  #print(OK)
  for i in range(m + 1):
    if OK[i] == n:
      cnt += 1
    else:
      pass
  print(cnt)
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
if __name__ == '__main__':
	S = input()
	T = input()

	set_S = set(S)
	set_T = set(T)
	if len(set_S) != len(set_T):
		print("No")
		exit()

	dic = dict()

	flg = True
	for x,y in zip(S,T):
		if x not in dic:
			dic[x] = y
		else:
			if dic[x] != y:
				flg = False
				break
	
	if flg :
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 9352
# 入力
a,b = gets.chomp.split.map(&:to_i)

# 配列にする
c = a+b
cookies = [a,b,c]

d = cookies.find { |n| n % 3 == 0 }

# こたえ
if d == nil
  puts "Impossible"
else
  puts "Possible"
end

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

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

  if(regex_match(S, regex("(hi)+"))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll h, m, hh, mm, k;
    cin >> h >> m >> hh >> mm >> k;
    
    ll s = h * 60 + m;
    ll e = hh * 60 + mm - k;
    
    cout << e - s << endl;
    
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int N = 8 + 10;
string s[N];
int n, m, mark[N][N];
int dx[] = {1, 0}, dy[] = {0, 1};
bool isval(int x, int y) {
	if (x >= 0 && y >= 0 && x < n && y < m && s[x][y] == '#') 
		return true;
	return false;
}
void dfs(int x, int y) {
	mark[x][y] = 1;
	for (int i = 0; i < 2; i++) {
		if (isval(x + dx[i], y + dy[i])) {
			dfs(x + dx[i], y + dy[i]);
			return;
		}
	}
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	dfs(0, 0);
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < m; j++) {
			if (isval(i, j) && !mark[i][j]) {
				cout << "Impossible";
				return 0;
			}		
		}
	cout << "Possible";
	return 0;
}	


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
X=[0]*(10**5+1)
for i in range(N):
  X[A[i]]+=1
Q=int(input())
B,C=0,0
P=sum(A)
for i in range(Q):
  B,C=map(int,input().split())
  P+=(C-B)*X[B]
  X[C]+=X[B]
  X[B]=0
  print(P)


Measured memory_bytes: 83948
#include <stdio.h>

#define MAX_H 500001

int parent(int );
int left(int );
int right(int );
void maxHeapify(int *,int, int);
void buildMaxHeap(int *,int);

int main(){
  int H=0;
  int A[MAX_H];
  int i=0;

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A,H);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int *A,int i, int H){
  int l=0;
  int r=0;
  int largest=0;
  int swap=0;
  l=left(i);
  r=right(i);

  if( (l<=H) && (A[l]>A[i]) ) largest=l;
  else largest=i;

  if( (r<=H) && (A[r]>A[largest]) ) largest=r;

  if(largest!=i){
    swap=A[i];
    A[i]=A[largest];
    A[largest]=swap;
    maxHeapify(A,largest,H);
  }
  
}

void buildMaxHeap(int *A,int H){
  int i=0;
  for(i=H/2; i>=1;i--) maxHeapify(A,i,H);
}



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

#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
int add(int a,int b){
	return (a + b)%mod;
}
int sub(int a,int b){
	return add(a,mod - 1);
}
int mul(int a,int b){
	return (a*b)%mod;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n,k;
    cin >> n >> k;
    int cnt[n] = {0};
    ffor(i,k){
    	int x;
    	cin >> x;
    	ffor(j,x){
    		int z;
    		cin >> z;
    		--z;
    		cnt[z]++;
    	}
    }
    int ans = 0;
    ffor(i,n){
    	if(cnt[i] == 0)ans++;
    }
    cout << ans;
}

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

using namespace std;using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int N;
  cin >> N;
  const int P = 100000;
  UnionFind uf(P + P + P);
  vector< int > X(N), Y(N);
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    --X[i], --Y[i];
    uf.unite(i, P + Y[i]);
    uf.unite(i, P + P + X[i]);
  }
  set< int > x[P + P + P], y[P + P + P];
  for(int i = 0; i < N; i++) {
    x[uf.find(i)].emplace(X[i]);
    y[uf.find(i)].emplace(Y[i]);
  }
  int64 ret = 0;
  for(int i = 0; i < P + P + P; i++) {
    int s = x[i].size(), t = y[i].size();
    ret += 1LL * s * t;
  }
  cout << ret - N << endl;
}




Measured memory_bytes: 35072
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k;cin>>n>>k;
  V<int> e(n);
  rep(i,0,n){
    cin>>e[i];
    e[i]--;
  }

  V<int> used(n,-1);
  deque<int> vis(0);
  queue<int> q;
  q.push(0);
  q.push(0);
  used[0]=0;

  while(q.size()){
    int now=q.front();q.pop();
    int dis=q.front();q.pop();
    vis.pb(now);

    if(used[e[now]]==-1){
      q.push(e[now]);
      q.push(dis+1);
      used[e[now]]=dis+1;
    }else{
      int pre=used[e[now]],per=dis+1-pre;
      if(k<=dis){
        cout<<vis[k]+1<<ENDL;
      }else{
        k-=pre;
        k%=per;
        cout<<vis[pre+k]+1<<ENDL;
      }
      return 0;
    }
  }

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

using namespace std;

using int64 = long long;

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

  int64 a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << min(a * b, min(b * c, c * a)) << endl;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var S = cin.ReadLine;

            var len = S.Length;
            long ans = 0;

            for (int mask = 0; mask < 1 << len - 1; mask++){
                long x = 0;
                for (int i = 0; i < len; i++){
                    x = x * 10 + S[i] - '0';
                    if (i == len - 1 || (mask >> i & 1) == 1){
                        ans += x;
                        x = 0;
                    }
                }
            }

            WriteLine(ans);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

struct Node{
    int key;
    Node* prev;
    Node* next;
};

Node* nil;

void init(){
    nil=(Node*)malloc(sizeof(Node));
    nil->prev=nil;
    nil->next=nil;
    nil->key=1000000009;
}

void insert(int key){
    Node* np=(Node*)malloc(sizeof(Node));
    np->key=key;
    np->next=nil->next;
    np->prev=nil;
    nil->next->prev=np;
    nil->next=np;
    if(nil->prev==nil)nil->prev=np;
}

void deleteFirst(){
    Node* np=nil->next;
    if(np==nil)return;
    nil->next->next->prev=nil;
    nil->next=nil->next->next;
    free(np);
}

void deleteLast(){
    Node* np=nil->prev;
    if(np==nil)return;
    nil->prev->prev->next=nil;
    nil->prev=nil->prev->prev;
    free(np);
}

void deleteX(int x){
    Node* np=nil->next;
    while(np!=nil){
        if(np->key==x){
            np->next->prev=np->prev;
            np->prev->next=np->next;
            free(np);
            return;
        }
        np=np->next;
    }
    return;
}

void printList(){
    Node* np=nil->next;
    while(np!=nil->prev){
        cout<<np->key<<" ";
        np=np->next;
    }
    cout<<np->key<<endl;
}

int main(void){
    int n,i,x;
    char order[100];
    init();
    cin>>n;
    for(i=0;i<n;i++){
        cin>>order;
        if(order[0]=='i'){
            cin>>x;
            insert(x);
        }
        else if(order[6]=='F'){
            deleteFirst();
        }
        else if(order[6]=='L'){
            deleteLast();
        }
        else{
            cin>>x;
            deleteX(x);
        }
    }
    printList();
}



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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B; cin >> N >> A >> B;
  string str; cin >> str;
  vector<string> ans(N, "No");
  int pass = 0;
  int foreignpass = 0;
  for(int i = 0; i < str.length(); i++){
    if(str[i] == 'a'){
      if(pass < A + B){
	pass++;
	ans[i] = "Yes";
      }
    }else if(str[i] == 'b'){
      if(pass < A + B && foreignpass < B){
	pass++;
	ans[i] = "Yes";
      }
      foreignpass++;
    }
  }
  for(int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 6224
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

vector<int> in;
ll val[200010];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, tmp, i;
    cin >> n;
    memset(val, 0, sizeof(val));
    rep(i, n) {
        cin >> tmp;
        in.push_back(tmp);
        val[tmp]++;
    }
    ll ans(0);
    rep(i, n + 1) {
        if (val[i]) {
            ans += val[i] * (val[i]- 1) / 2;
        }
    }
    // cout << ans << endl;
    rep(i, n) {
        int now = val[in[i]];
        ll tans = ans;
        if (now >= 2) {
            tans -= now * (now -1) / 2;
            tans += (now-1) * (now - 2) / 2;
        }
        cout << tans << endl;
    }
}


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

int main(){
  int A,B,K;cin>>A>>B>>K;
  int ans=101;
  int count=0;
  while(1){
    ans--;
    if(A%ans==0 && B%ans==0) count++;
    if(count==K) break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
      long long int n,k,i,a,su=0;
        cin>>n>>k;
        vector<long long int>s;
        for(i=0;i<n;i++)
        {
                cin>>a;
                s.push_back(a);
        }
        sort(s.begin(),s.end());
        i=0;
        while(k--)
        {
                su=su+(s[i]);
                i++;
        }
        cout<<su<<endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

//-----------------------------------------------------------------------------

int n;

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

	cin>>n;
	ll prv=2,crt=1,ans=1;
	REP(i,n-1) {
		ans=prv+crt;
		prv=crt,crt=ans;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String s[] = br.readLine().split("");
		List<String> strS = new ArrayList<>();
		List<String> strA = new ArrayList<>();

		for (int i = 0; i < s.length; i++) {
			strS.add(s[i]);
			strA.add(s[i]);
		}

		List<String> set = new ArrayList<>();
		Collections.addAll(set, "-1");

		while (true) {
			boolean flag = false;
			for (int i = 0; i < strS.size() - 1; i++) {
				if (strS.get(i).equals("(") && strS.get(i + 1).equals(")")) {
					strS.set(i, "-1");
					strS.set(i + 1, "-1");
					flag = true;
				}
			}
			if (!flag) {
				break;
			}
			strS.removeAll(set);
		}

		int left = 0;
		int right = 0;
		for (int i = 0; i < strS.size(); i++) {
			if (strS.get(i).equals("(")) {
				left++;
			} else {
				right++;
			}
		}

		for (int i = 0; i < right; i++) {
			System.out.print("(");
		}

		for (int i = 0; i < strA.size(); i++) {
			System.out.print(strA.get(i));
		}

		for (int i = 0; i < left; i++) {
			System.out.print(")");
		}
		System.out.println();
	}
}

Measured memory_bytes: 33064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
const int INF = 1000000009;

long n, k;

int main(){
	scanf("%ld%ld", &n, &k);
	if(k == 0){
		printf("%ld\n", n*n);
		return 0;
	}
	long ans = 0;
	for(long i = k+1; i <= n; i++){
		ans += n / i * (i-k);
		ans += std::max((long)0, n%i - k + 1);
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <set>

int main(void){
    Cin(int, n, k);
    Cins(int, n, p);
    
    vc<int> l(n, 1);
    For(i, n-1){
        if(p[i+1] > p[i]) l[i+1] = l[i]+1;
    }
    // Couts(l);
    
    int ans = (l[k-1] == k) ? 0 : 1;
    set<int> s(p.begin(), p.begin() + k);
    For(i, n-k){
        int out = p[i], in = p[i+k];
        // Couts(s);
        // printf("out %d in %d %s\n", out, in, (out == *s.begin() && in > *s.rbegin()) || l[i+k] >= k ? "NG" : "OK");
        ans ++;
        if(l[i+k] >= k) ans --;
        else if(out == *s.begin() && in > *s.rbegin()) ans --;

        s.erase(out);
        s.insert(in);
    }
    DeSort(l);
    if(l[0] >= k) ans ++;
    Cout(ans);
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

    ll n, a, b;
    cin >> n >> a >> b;
    if((b - a) % 2 == 0){
        cout << (b - a) / 2 << endl;
        return 0;
    }
    ll res = a - 1;
    ++res;
    res = res + (b - res) / 2;

    ll tmp = n - b;
    ++tmp;
    tmp = tmp + (n - (a + tmp)) / 2;
    
    res = min(res, tmp);
    cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int index = b - a;
        int height = (1 + index) * index / 2;
        Console.WriteLine(height - b);
    }
}


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

void fun(ll n , ll s){
 ll a[n];
 ll sum=0;
 ll r,l;
 l=0;
 r=n-1;
 ll ans=n;
 for(ll i=0;i<n;i++){cin>>a[i];sum+=a[i];}
 if(sum<s)ans=0;
 while(l<=r && ans){
 if(a[l]<a[r]&&sum-a[l]>=s){

    sum-=a[l++];ans--;

 }else if(sum-a[r]>=s){
    sum-=a[r--];ans--;

 }else break;;;


}
 cout << ans << "\n";
}
int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll n,m;
 cin >>n>>m;
 bool a[n];
 ll b[n];
 for(ll i=0;i<n;i++){
  a[i]=false;
  b[i]=1;
 }
 a[0]=true;
 for(ll i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    x--;
    y--;
    if(a[x])a[y]=true;
    b[x]--;
    b[y]++;
    if(b[x]==0)a[x]=false;
 }
 ll c=0;
 for(ll i=0;i<n;i++){
    if(a[i]&&b[i]>0)c++;
 }
 cout << c;
}


Measured memory_bytes: 4460
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

 void solve() {
    int n;
    cin>>n;
    int sm=0;
    rep(i,1,n+1) {
		  if(!(i%3==0 || i%5==0) )  {
			    sm+=i;
			  }
		}
		cout<<sm<<endl;              
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 3640
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int MAX_C = 2010;
long long Com[MAX_C][MAX_C] = {0};

int main(){
  int N; cin >> N;
  int x = 800*N;
  int y = (N/15)*200;
  cout << x-y << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    double r = sc.nextDouble();
    double a = r*r*Math.PI;
    double b = 2*r*Math.PI;
    System.out.println(String.format("%.5f",a)+" "+String.format("%.5f",b));
  }
}


Measured memory_bytes: 28316