akhauriyash/Code-Regression huggingface dataset:
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=1000010;
const double Pi=acos(-1.0);
struct node
{
	double x,y;
	node operator+(const node b)const{return (node){x+b.x,y+b.y};}
	node operator-(const node b)const{return (node){x-b.x,y-b.y};}
	node operator*(const double b)const{return (node){b*x,b*y};}
}p[N];
double cross(node a,node b){return a.x*b.y-a.y*b.x;}
double len(node a){return sqrt(a.x*a.x+a.y*a.y);}
double dis(node a,node b){return len(a-b);}
node rotate(node p,double b){double c=cos(b),s=sin(b);return (node){p.x*c-p.y*s,p.x*s+p.y*c};}
struct circle{node o;double r;}o;
struct line{node a,v;};
int n;
line ghl(line a){node m=a.a+a.v*0.5;return (line){m,rotate(a.v,Pi/2)};}
node intersecion(line a,line b)
{
	node c=b.a-a.a;
	double t=cross(b.v,c)/cross(b.v,a.v);
	return a.a+a.v*t;
}
int main()
{
	n=gi();
	for(int i=1;i<=n;i++)scanf("%lf%lf",&p[i].x,&p[i].y);
	random_shuffle(p+1,p+n+1);
	for(int i=1;i<=n;i++)
		if(dis(o.o,p[i])>o.r)
		{
			o.r=0;o.o=p[i];
			for(int j=1;j<i;j++)
			{
				if(dis(p[j],o.o)>o.r)
				{
					o.o=(p[i]+p[j])*0.5;o.r=dis(p[i],p[j])*0.5;
					for(int k=1;k<j;k++)
						if(dis(p[k],o.o)>o.r)
						{
							o.o=intersecion(ghl((line){p[i],p[j]-p[i]}),ghl((line){p[i],p[k]-p[i]}));
							o.r=dis(p[i],o.o);
						}
				}
			}
		}
	printf("%.10lf\n",o.r);
	return 0;
}


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

int main() {
    long int n;
    cin>>n;
    long int a[n],b[n];
    vector<long int> v(n);
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long int i=0;i<n;i++)
    {
        cin>>b[i];
        v[i]=(a[i]-b[i]);
    }
    sort(v.begin(),v.end());
    long int ans=0;
  /*  for(long int i=0;i<n;i++)
    {
     //   cin>>b[i];
       // v.push_back(a[i]-b[i]);
        cout<<v[i]<<" ";
        
    }*/
    for(long int i=n-1;i>=0;i--)
    {
        if(v[i]>0)
        {
            ans+=v[i];   
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;

typedef long long ll;

long long myGcd(long long a, long long b)
{
	if (a % b == 0)return b;
	return myGcd(b, a % b);
}

int myGcd(int a, int b)
{
	if (a % b == 0)return b;
	return myGcd(b, a % b);
}

long long myLcm(long long a, long long b)
{
	return a * b / myGcd(a, b);
}

int myLcm(int a, int b)
{
	return a * b / myGcd(a, b);
}


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

	int N;

	cin >> N;

	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)
	{
		cout << "hon" << endl;
	}
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
	{
		cout << "pon" << endl;
	}
	else if(N % 10 == 3)
	{
		cout << "bon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3648
/* Filename: ABC076B.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int N = input.nextInt();
			int K = input.nextInt();
			
			int num = 1;
			while(N > 0){
				num = Math.min(num * 2, num + K);
				--N;
			}
			
			System.out.println(num);
		}
	}

}


Measured memory_bytes: 20816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll max_col[100005][15]={0};
ll nxt[100005][15]={0};
ll col[100005]={0};
ll ans[100005]={0};
vector<P> node;
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    node.push_back(P(a,b));
  }
  ll q;
  cin>>q;
  for(int i=1;i<=q;i++){
    ll v,d;
    cin>>v>>d>>col[i];
    max_col[v][d]=i;
    ans[v]=i;
  }
  for(int i=1;i<=n;i++){
    for(int j=10;j>=0;j--) max_col[i][j]=max(max_col[i][j],max_col[i][j+1]);
  }
  for(int turn=1;turn<=10;turn++){
    for(int i=1;i<=n;i++){
      for(int j=0;j<=10;j++){
        nxt[i][j]=max_col[i][j];
      }
    }
    for(int i=0;i<m;i++){
      ll s=node[i].first,t=node[i].second;
      for(int j=0;j<=10;j++){
        ll mv=max(max_col[s][j],max_col[t][j]);
        nxt[s][j]=max(nxt[s][j],mv);
        nxt[t][j]=max(nxt[t][j],mv);
      }
    }
    for(int i=1;i<=n;i++){
      for(int j=0;j<=10;j++){
        max_col[i][j]=nxt[i][j];
        nxt[i][j]=0;
      }
    }
    for(int i=1;i<=n;i++) ans[i]=max(ans[i],max_col[i][turn]);
  }
  for(int i=1;i<=n;i++) cout<<col[ans[i]]<<endl;
}


Measured memory_bytes: 27376
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <math.h>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

void  Yes() {
	cout << "Yes" << endl;
	return;
}

void  No() {
	cout << "No" << endl;
	return;
}

int main() {

	// 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	int N, A, B;
	string S;

	cin >> N >> A >> B >> S;

	int cnt = 0;
	int kaigaiCnt = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'a') {
			if (cnt < A + B) {
				Yes();
				++cnt;
			}
			else {
				No();
			}
		}
		else if (S[i] == 'b') {
			if (cnt < A + B && kaigaiCnt < B) {
				Yes();
				++cnt;
				++kaigaiCnt;
			}
			else {
				No();
			}
		} 
		else if (S[i] == 'c') {
			No();
		}
	}

	return 0;
}


Measured memory_bytes: 832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n;
    int cnt=0;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    if(n<3){
        cout << 0 << endl;
        return 0;
    }
    else{
        rep(i,n-2){
            for(int j=i+1; j<n-1; j++){
                for(int k=j+1; k<n; k++){
                    ll a=l[i],b=l[j],c=l[k];
                    if(a != b && b != c && c != a){
                        bool ok=true;
                        if(a+b<=c) ok=false;
                        if(b+c<=a) ok=false;
                        if(c+a<=b) ok=false;
                        if(ok) cnt++;
                    }
                }
        }
    }
    cout << cnt << endl;
}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
const int mod=1000000007;
#define fi first
#define se second
int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> AC(n,0),count(n+1,0);
    vector<P> sub;
    for(int i=1;i<s.size();i++){
          if(s.at(i-1)=='A'&&s.at(i)=='C'){
              AC.at(i)++;
          }
    }
    for(int i=0;i<n;i++){
        count.at(i+1)=AC.at(i)+count.at(i);
    }
    for(int i=0;i<q;i++){
        int a,b;
        cin>>a>>b;
        sub.push_back(P(a,b));
    }
    for(int i=0;i<q;i++){
        cout<<count.at(sub.at(i).se)-count.at(sub.at(i).fi)<<endl;
    }
    
    
}

Measured memory_bytes: 2676
S = input()
T = input()
k = {}
o = {}
res = "Yes"
for i in range(len(S)):
    if S[i] in k:
        if k[S[i]] != T[i]:
            res = "No"
            break
    else:
        k[S[i]] = T[i]
        
for i in range(len(T)):
    if T[i] in o:
        if o[T[i]] != S[i]:
            res = "No"
            break
    else:
        o[T[i]] = S[i]
    
print(res)


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

pi in(){
    int x,y;
    cin >>x >>y;
    return {x,y};
}

int main(){
    int n;
    cin >>n;

    vector<pi> r(n),b(n);
    rep(i,n) r[i] = in();
    sort(all(r));
    rep(i,n) b[i] = in();
    sort(all(b));

    int ridx = 0;
    set<int> y;
    int ans = 0;
    rep(i,n){
        int bx = b[i].fi, by = b[i].se;

        while(ridx<n && r[ridx].fi<bx){
            y.insert(r[ridx].se);
            ++ridx;
        }

        auto itr = y.lower_bound(by);
        if(itr != y.begin()){
            --itr;
            y.erase(itr);
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef pair<int, int> pi;
const int MAXN = 1e5 + 1;
int n, m;
pi arr[MAXN];

bool cmp(pi a, pi b) {
	return a.second < b.second;
}

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

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> arr[i].first >> arr[i].second;
	}

	sort(arr, arr + m, cmp);

	int x = arr[0].first;
	int y = arr[0].second;

	for (int i = 1; i < m; i++) {
		x = max(x, arr[i].first);
	}

	if (x > y) cout << 0 << "\n";
	else cout << y - x + 1 << "\n";

	
	return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
b = 1
ans = 0
for i in range(k - 1, n):
    ans += b * (a[i] - a[n - i - 1])
    ans %= mod
    b = (i+1)*pow(i-k+2, mod - 2, mod) * b % mod
print(ans)

Measured memory_bytes: 14040
two = ["SS", "SW", "WS", "WW"]
n = int(input())
s = input()
flip = {"S":"W", "W":"S"}
flag = False

for i in two:
    for j in s[1:]:
        if j == 'o':
            if i[-1] == 'S':
                i += i[-2]
            else:
                i += flip[i[-2]]
        else:
            if i[-1] == 'S':
                i += flip[i[-2]]
            else:
                i += i[-2]
    if i[0] == i[-1]:
        if s[0] == 'o':
            if i[0] == 'S' and i[-2] == i[1] or i[0] == 'W' and i[-2] != i[1]:
                flag = True
        else:
            if i[0] == 'S' and i[-2] != i[1] or i[0] == 'W' and i[-2] == i[1]:
                flag = True
    if flag:
        print(i[:-1])
        break
if not flag:
    print(-1)


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

using namespace std;

typedef long long int64;

void Calculation()
{
  int64 A, B, C;
  cin >> A >> B >> C;

  if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << 0 << endl;
  } else {
    cout << min({A * B, B * C, A * C}) << endl;
  }
}

int main()
{
  Calculation();
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;

int main(){
	ll n,x;
	cin>>n>>x;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	for(ll i=0; i<n-1; i++){
		if(a[i]+a[i+1]>x){
			ll sum=a[i]+a[i+1];
			ll fix=sum-x;
			if(a[i+1]>=fix) {
				a[i+1] -=fix;
				ans +=fix;
			}
			else {
				ans +=fix;
				a[i] -=fix-a[i+1];
				a[i+1]=0;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1152
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

int c[100010];

signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  int h, w, k;
  cin >> h >> w >> k;
  bool g[h][w];
  char a;
  int ans = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++){
      cin >> a;
      if (a == '.')
	g[i][j] = 0;
      else
	g[i][j] = 1;
    }
  for (int i = 0; i < pow(2, h); i++)
    for (int j = 0; j < pow(2, w); j++){
      Vi vi, vj;
      int ii = i;
      while (ii)
	vi.pb(ii % 2), ii /= 2;
      int jj = j;
      while(jj)
	vj.pb(jj % 2), jj /= 2;
      bool gg[h][w];
      for (int ii = 0; ii < h; ii++)
	for (int jj = 0; jj < w; jj++)
	  gg[ii][jj]=g[ii][jj];
      for (int ii = 0; ii < vi.size(); ii++)
	if (vi[ii])
	  for (int jj = 0; jj < w; jj++)
	    gg[ii][jj]=0;
      for (int jj = 0; jj < vj.size(); jj++)
	if (vj[jj])
	  for (int ii = 0; ii < h; ii++)
	    gg[ii][jj]=0;
      int cnt = 0;
      for (int ii = 0; ii < h; ii++)
	for (int jj = 0; jj < w; jj++){
	  if (gg[ii][jj])
	    cnt++;
	}
      if (cnt == k){
	ans++;
      }
    }
  cout << ans << endl;
}


Measured memory_bytes: 4060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC103.D2
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var m = sc.Nextint();
            var demands = Enumerable.Range(0, m).Select(i => new { A = sc.Nextint(), B = sc.Nextint() }).ToArray();

            var maxRight = Enumerable.Repeat(n + 1, n).ToArray();
            foreach (var item in demands)
            {
                maxRight[item.A] = Math.Min(maxRight[item.A], item.B);
            }
            var cnt = 0;
            var r = n + 1;
            for (int l = 1; l < n; l++)
            {
                r = Math.Min(maxRight[l], r);
                if (r <= l + 1)
                {
                    cnt++;
                    r = n + 1;
                }
            }
            Console.WriteLine(cnt);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 25544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

ll X[4][4];
bool ch(){
	//FOR(i,1,4)FOR(j,1,4)if(X[i][j]<0)return false;
	ll s=X[1][3]+X[2][2]+X[3][1];
	ll t=X[1][1]+X[2][2]+X[3][3];
	if(s!=t)return false;
	FOR(i,1,4){
		ll a=0,b=0;
		FOR(j,1,4){
			a+=X[i][j];
			b+=X[j][i];
		}
		if(a!=s || b!=s)return false;
	}
	return true;
}


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

	cin>>X[1][1]>>X[1][2]>>X[2][2];
	FOR(i,-1000,1001){
		X[1][3] = i;
		ll sum = X[1][1]+X[1][2]+i;
		X[3][1]=sum-X[2][2]-X[1][3];
		X[2][1]=sum-X[1][1]-X[3][1];
		X[2][3]=sum-X[2][2]-X[2][1];
		X[3][2]=sum-X[1][2]-X[2][2];
		X[3][3]=sum-X[1][1]-X[2][2];
		if(ch())break; 
	}
	FOR(i,1,4){
		cout << X[i][1];
		FOR(j,2,4){
			cout << " " << X[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<ll> a;
    rep(i, n){
        ll x;
        cin >> x;
        a.push_back(x);
    }
    ll money=1000, kabu=0;
    rep(i, n-1){
        // buy phase
        if(kabu==0){
            if(a[i]<a[i+1]){
                kabu += money / a[i];
                money -= kabu * a[i];
            }
        }else{ // sell phase
          if (a[i] > a[i + 1]) {
            money += kabu * a[i];
            kabu = 0;
          }
        }
    }
    if(kabu!=0){
      money += kabu * a[n-1];
      kabu = 0;
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 3620
import itertools
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M, Q = map(int, input().split())
    A_ = itertools.combinations_with_replacement(range(1, M + 1), N)
    abcd = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        a -= 1
        b -= 1
        abcd.append((a, b, c, d))

    ans = 0
    for A in A_:
        tmp = 0
        for a, b, c, d in abcd:
            if A[b] - A[a] == c:
                tmp += d

        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9216
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int db=d-b;
    int ca=c-a;
    
    cout<<c-db<<" "<<d+ca<<" "<<a-db<<" "<<b+ca<<endl;
    
    return 0;
}

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

using namespace std;

int n, a[200000], ans;
bool in[1000001];

int main()
{
    cin >> n;
    for(int i = 0; i<n; i++)
        cin >> a[i];
    sort(a,a+n);
    for(int i = 0; i<n; i++)
    {
        bool found = false;
        for(int j = 1; j*j<=a[i]; j++)
            if(a[i]%j==0)
                if((in[j])||(in[a[i]/j]))
                    found = true;
        if(!found)
            ans++;
        if((!found)&&(i<n-1)&&(a[i]==a[i+1]))
            ans--;
        in[a[i]] = true;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5228
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


void PrimeFact(ll n,map<ll,ll>& mp){
    while(n!=1){
        if(n == 2 || n == 3){
            mp[n]++; n/=n;
            continue;
        }
        bool prime_flag = false;
        for(ll i = 2;i*i <= n;i++){
            if(n%i==0){
                mp[i]++; n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){mp[n]++; n/= n;}
    }
}

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    { // check pairwise
        map<ll,int> prime;
        bool ok = true;
        for(int i = N-1; i >= 0; i--){
            map<ll,ll> mp;
            PrimeFact(A[i], mp);
            
            for(auto p:mp){
                if(prime[p.first]){
                    ok = false;
                    break;
                }else{
                    prime[p.first]++;
                }
            }
        }
        if(ok){
            return "pairwise coprime";
        }
    }
    {
        // check setwise
        ll GCD = 0;
        for(auto a:A) GCD = gcd(GCD,a);
        if(GCD == 1){
            return "setwise coprime";
        }
    }
    return "not coprime";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 15756
from collections import Counter
n = int(input())
s = [None] * n
for i in range(n):
  s[i] = Counter(input())
ans = ""
for c in "abcdefghijklmnopqrstuvwxyz":
  cc = 50
  for si in s:
    cc = min(si.get(c, 0), cc)
  ans += c * cc
print(ans)

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

int main() {
int N,K;
  cin >> N >> K;
  if(N <= K){
  	cout << 0 << endl;
  }
  else{
  	vector<int> hp(N);
  	for(int i = 0; i < N; i++){
 	 	cin >> hp[i];
 	 }
  	sort(hp.begin(), hp.end());
  	int64_t ans = 0;
 	 for(int i = 0; i < N-K; i++){
 	 	ans += hp[i];
 	 }
  	cout << ans << endl;
  
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

long long mod = 998244353;

int main(){
    long long n;
    cin >> n;

    vector<long long> d(n);
    vector<long long> cnt(n, 0);

    for(long long i = 0; i < n; i++){
        cin >> d[i];
        if(i == 0 and d[i] != 0){
            printf("0\n");
            return 0;
        }
        else if(i != 0 and d[i] == 0){
            printf("0\n");
            return 0;
        }

        cnt[d[i]]++;
    }


    for(long long i = 0; i < n; i++){
        if(i > 0 and cnt[i] > 0 and cnt[i-1] == 0){
            printf("0\n");
            return 0;
        }
    }

    long long ans = 1;
    long long prev = 0;
    long long now = 0;

    for(long long i = 0; i < n; i++){
        if(i == 0){
            prev = cnt[i];
            prev %= mod;
            continue;
        }
        now = cnt[i];
        prev %= mod;
        now %= mod;

        long long start = 1;
        for(long long j = 0; j < now; j++){
            start *= prev;
            start %= mod;
        }
        ans *= start;
        ans %= mod;
        prev = now;
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;
int n , k;

int mul (long long a , long long b) {
    a = (a % MOD + MOD) % MOD;
    b = (b % MOD + MOD) % MOD;
    return a * b % MOD;
}

pair<bool , int> max_pos (vector<int> pos , vector<int> neg) {
    sort(pos.begin() , pos.end());
    sort(neg.rbegin() , neg.rend());

    int ans = 1 , rem = k;
    while (rem) {
        if ((rem == 1 || neg.size() < 2) && pos.empty())
            return {0 , 0};

        if (rem >= 2 && neg.size() >= 2) {
            long long f = -1e18 , s = -1e18;

            if (neg.size() >= 2)
                f = neg[neg.size() - 1] * 1ll * neg[neg.size() - 2];

            if (pos.size() >= 2)
                s = pos[pos.size() - 1] * 1ll * pos[pos.size() - 2];

            if (f > s) {
                neg.pop_back();
                neg.pop_back();
                ans = mul(ans , f);
                rem -= 2;
                continue;
            }
        }

        ans = mul(ans , pos.back());
        pos.pop_back();
        rem--;
    }

    return {1 , ans};
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    cin >> n >> k;

    vector<int> pos , neg;

    int sec = 1;
    for (int i = 0 ;i < n ;i++) {
        int x;
        cin >> x;
        sec = mul(sec , x);
        if (x >= 0)
            pos.push_back(x);
        else
            neg.push_back(x);
    }


    auto ans = max_pos(pos , neg);
    if (ans.first)
        cout << ans.second;
    else {
        if (pos.empty()) {
            sort(neg.rbegin() , neg.rend());
            sec = 1;
            for (int i = 0 ;i < k ;i++)
                sec = mul(sec , neg[i]);

        }
        cout << sec;
    }
}

Measured memory_bytes: 4792
n=int(input())
x,y=[list(map(int,input().split()))for _ in range(2)]
d=[abs(s-t)for s,t in zip(x,y)]
f=lambda n:sum([s**n for s in d])**(1/n)
print(f(1),f(2),f(3),max(d),sep='\n')


Measured memory_bytes: 5648
from fractions import gcd

# 最小公倍数
def lcm(x, y):
  return (x * y) // gcd(x, y)


def num(n1,n2,n3):
  return n1 - (n1//n2) - (n1//n3) + (n1//lcm(n2,n3))


A,B,C,D = map(int,input().split())
print(num(B,C,D) - num(A-1,C,D))


Measured memory_bytes: 5112
defmodule Main do
  def main do
    a = IO.read(:line) |> String.trim
    b = IO.read(:line) |> String.trim
    c = IO.read(:line) |> String.trim
    d = IO.read(:line) |> String.trim
    a = String.to_integer(a)
    b = String.to_integer(b)
    c = String.to_integer(c)
    d = String.to_integer(d)
    IO.puts(Enum.min([a,b]) + Enum.min([c,d]))
  end
end


Measured memory_bytes: 30692
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define ins insert
#define er erase
#define f(i,a,b) for(i=a;i<b;++i)
#define rf(i,a,b) for(i=a;i>=b;--i)
#define tc int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int> 
#define vll vector<ll> 
#define vull vector<ull>
#define vc vector<char>
#define vst vector<string>
#define bs bitset
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b) 
#define lb lower_bound
#define ub upper_bound
#define nl "\n" 
#define sp " "
using namespace std;

//LET'S PLAY THE GAME!!

bool cmp(pii x, pii y){
    if(x.ff!=y.ff)return x.ff<y.ff;
    return x.ss<y.ss;
}

int main(){
    fast;
    
    int n,k;cin>>n>>k;
    if(k> ((n-1)*(n-2))/2){
        cout<<"-1";return 0;
    }
    vector<pii>v,ans;
    int i,j;
    f(i,1,n+1){
        f(j,i+1,n+1)v.pb(mp(i,j));
    }
    
    sort(all(v),cmp);
    
    
    f(i,0,v.size()){
        if(!k || v[i].ss==n)ans.pb(v[i]);
        else k--;
    }
    
    cout<<ans.size()<<nl;
    for(auto p:ans)cout<<p.ff<<sp<<p.ss<<nl;
    
    return 0;
}
// AND THE GAME IS OVER!!

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	vector<long long int>w(M);
	for (auto &i : w)cin >> i;
	long long int ans = *min_element(v.begin(), v.end()) + *min_element(w.begin(), w.end());
	while (K--) {
		cin >> L >> R >> H;
		L--, R--;
		ans = min(ans, v[L] + w[R] - H);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import math

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

result = 10 ** 10
for i in A:
    count = 0
    for _ in range(result):
        if i % 2 == 0:
            i /= 2
            count += 1
        else:
            break
    result = min(result, count)

print(int(result))

Measured memory_bytes: 9228
S = input()

dp = [[0 for _ in range(3+ 1)] for _ in range(len(S) + 1)]
dp[0][0] = 1

B = 10 ** 9 + 7
for i in range(1, len(S) + 1):
    if S[i - 1] == 'A':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][1] += dp[i - 1][0]
    elif S[i - 1] == 'B':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][2] += dp[i - 1][1]
    elif S[i - 1] == 'C':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][3] += dp[i - 1][2]
    else:
        dp[i][0] += dp[i - 1][0] * 3
        dp[i][1] += dp[i - 1][1] * 3
        dp[i][2] += dp[i - 1][2] * 3
        dp[i][3] += dp[i - 1][3] * 3

        dp[i][1] += dp[i - 1][0]
        dp[i][2] += dp[i - 1][1]
        dp[i][3] += dp[i - 1][2]

    for k in range(4):
        dp[i][k] %= B


print(dp[len(S)][3])

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

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

  int A, B, C, X; cin >> A >> B >> C >> X;
  int ans = 0;
  for (int x = 0; x <= A; x++) {
    for (int y = 0; y <= B; y++) {
      int z = X - 500 * x - 100 * y;
      if (z >= 0 && z % 50 == 0 && z / 50 <= C) ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
parseInt = x -> parse(Int, x)

a, b, c, d = map(parseInt, split(readline()))

l = lcm(c, d)

match_B = b - div(b, c) - div(b, d) + div(b, l)

match_A = a-1 - div(a-1, c) - div(a-1, d) + div(a-1, l)

println(match_B - match_A )


Measured memory_bytes: 110672
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int yakusu(int x){
    int count1=0;
    for(int i=1;i<=x;i++){
        if(x%i==0){
            count1++;
        }
    }
    return count1;
}


int main(){
    int n;cin >> n;
    
    int count=0;
    for(int i=1;i<=n;i++){
        if(i%2){
            int tem = yakusu(i);
            if(tem==8){
                count++;
            }
        }
    }
    cout << count << endl;

     return 0;

}



Measured memory_bytes: 3632
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto str = line.chomp;
		string ans = "";
		int i;
		while (i < str.length) {
			if (str[i] == '@') {
				foreach (j; 0..str[i+1]-'0') {
					ans ~= str[i+2];
				}
				i += 3;
			} else {
				ans ~= str[i];
				i++;
			}
		}
		ans.writeln;
	}
}

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

int main(){
	int n;
	cin >> n;
	vector<long long> a(n);
	vector<long long> res(n);
	int s, x;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	s = a[0];
	for(int i=1; i<n; i++){
		if(i%2 == 0){
			s -= a[i];
		}else{
			s += a[i];
		}
	}
	x = s/2;
	res[0] = x;
	for(int i=1; i<n; i++){
		res[i] = a[i] - res[i-1];
	}
	for(int i=0; i<n; i++){
		res[i] *= 2;
	}
	cout << res[n-1] << " ";
	for(int i=0; i<n-1; i++){
		cout << res[i] << " ";
	}
	cout << endl;
}

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


using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

const int N = 100007;

int dp[N][3];

int act[N][3];

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> act[i][0] >> act[i][1] >> act[i][2];
    }
    for(int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2])+act[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2])+act[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1])+act[i][2];
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';
    
    
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, M;
   cin >> N >> M;
   int a[N], b[N];
   for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
   int c[M], d[M];
   for (int i = 0; i < M; i++) cin >> c[i] >> d[i];

   for (int i = 0; i < N; i++) {
      int ans = 1e9;
      int log = -1;
      for (int j = 0; j < M; j++) {
         int tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
         if (tmp < ans) {
            ans = tmp;
            log = j + 1;
         }
      }
      cout << log << endl;
   }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int n, m;

int main(int argc, char const *argv[]) {
    cin >> n >> m;
    set<int> st;
    vector<vector<ll>> g(n, vector<ll>(n, LINF));
    vector<ll> a(m), b(m), c(m);
    REP(i,m) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
        g[a[i]][a[i]] = g[b[i]][b[i]] = 0;
    }
    vector<vector<ll>> dp(g);
    int ans = 0;
    REP(j,n) REP(i,n) REP(k,n) dp[i][k] = min(dp[i][k], dp[i][j]+dp[j][k]);
    REP(i,n) {
        for (int j = 0; j < n; ++j) {
            if (dp[i][j] >= LINF) continue;
            REP(k,m) {
                ll tmp1 = dp[i][a[k]]+c[k]+dp[b[k]][j];
                if (dp[i][j] == tmp1) {
                    // printf("i = %d j = %d k = %d tmp = %lld dp = %lld\n", i,j,k,tmp1,dp[i][j]);
                    st.insert(k);
                }
            }
        }
    }
    ans = m-st.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    vector<vector<ll>> dp(N,vector<ll>(N,0));
    rep(i,N) dp[i][i]=a[i];
    rep(j,N){
        rep(i,N){
            if (j==0) dp[i][i+j]=a[i];
            if (j==0||i+j>=N) continue;
            dp[i][i+j]=max(a[i]-dp[i+1][i+j],a[i+j]-dp[i][i+j-1]);
        }
    }
    cout << dp[0][N-1] << endl;
}

Measured memory_bytes: 72576
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int g = C > D ? gcd(C, D) : gcd(D, C);
        long k = (long) C*D/g;
        long result = B - (B/C + B/D - B/k) - (A-1 - ((A-1)/C + (A-1)/D - (A-1)/k));
        System.out.println(result);
    }

    private static int gcd(int a, int b) {
        int temp = 0;
        while (a % b != 0) {
            temp = a;
            a = b;
            b = temp % b;
        }
        return b;
    }
}

Measured memory_bytes: 21844
n = int(input())
xlist = [int(iz) for iz in input().split()]

run = n-2
ans = 0

for i in range(run):
    a = xlist[i]
    b = xlist[i+1]
    c = xlist[i+2]

    if (a < b < c) or (c < b < a):
        ans +=1





print(ans)


Measured memory_bytes: 3060
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int sum(int n) {
  int a = n * (n+1) / 2;
  return a;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << sum(b-a) - b << endl;
  return 0;
}
//templete by private_yusuke

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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    ull L,R;
    cin >> L >> R;
    int ans = 2311000;
    for(long i=L;i<R;i++){
        for(long j=i+1;j<=R;j++){
            if(((i%2019)*(j%2019))%2019==0){
                cout << 0 << endl;
                exit(0);
            }
            if(((i%2019)*(j%2019))%2019<ans){
                ans = ((i%2019)*(j%2019))%2019;
            }
        }
    }
    ans %= 2019;
    cout << ans << endl;
    return 0;
}


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


int main(){
    ll x,y; cin >> x >> y;
    ll cnt = x;
    int ans = 0;
    for(ll i = 0; cnt <= y; i++){
        cnt *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
 
	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}
 
	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}
 
	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}
 
	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

typedef pair<ll, Pa> edge;

vector<Pa> x_vec;
vector<Pa> y_vec;
vector<edge> edges;

int main() {
	cin >> N;
	UnionFind tree(N);
	rep(i, N){
		cin >> A >> B;
		x_vec.push_back(Pa(A, i));
		y_vec.push_back(Pa(B, i));
	}
	sort(x_vec.begin(), x_vec.end());
	sort(y_vec.begin(), y_vec.end());

	rep(i, N-1){
		int cost = abs(x_vec[i].first - x_vec[i+1].first);
		edges.push_back(edge(cost, Pa(x_vec[i].second, x_vec[i+1].second)));
		cost = abs(y_vec[i].first - y_vec[i+1].first);
		edges.push_back(edge(cost, Pa(y_vec[i].second, y_vec[i+1].second)));
	}

	sort(edges.begin(), edges.end());

	ll ans = 0;
	rep(i, edges.size()){
		if(!tree.issame(edges[i].second.first, edges[i].second.second)){
			tree.merge(edges[i].second.first, edges[i].second.second);
			ans += edges[i].first;
		}
	}
	cout << ans;
}

Measured memory_bytes: 14560
import math
a, b, x = map(int, input().split())
if x == a**2 * b:
    print(0)
else:
    if x >= (0.5 * a**2 * b):
        z = (math.atan(a**3/(2*(a**2*b - x))))
        print(90 - math.degrees(z))
    else:
        z = (math.atan(2*x/(a * b**2)))
        print(90 - math.degrees(z))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N, K, Q, A;
  cin >> N >> K >> Q;
  vector<int> player(N, 0);
  for(int i = 0; i < Q; i++) {
    cin >> A;
    player[A - 1]++;
  }

  for(int i = 0; i < N; i++) {
    if(K - (Q - player[i]) <= 0) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3712
n=int(input())
a=sorted(list(map(int,input().split())))

if n%2==0:
  for i in range(0,n//2+1,2):
    if not a[i]==a[i+1]==i+1:
      print("0")
      exit(0)
  print(2**(n//2)%(10**9+7))

else:
  b=[0]+a
  for i in range(0,(n+1)//2+1,2):
    if not b[i]==b[i+1]==i:
      print("0")
      exit(0)
  print(2**((n-1)//2)%(10**9+7))

Measured memory_bytes: 14008
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
count = 0
for i in range(N):
	m1 = min(a_list[i], b_list[i])
	count += m1
	b_list[i] -= m1
	m2 = min(a_list[i + 1], b_list[i])
	count += m2
	a_list[i + 1] -= m2
print(count)


Measured memory_bytes: 18512