akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, m, A[N], a[N], b[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	int odd = 0;
	for(int i = 1; i <= n; i++) {
		cin >> A[i];
		if(A[i] % 2 == 1)
			odd++;
	}
	if(m == 1) {
		if(A[1] == 1) {
			cout << A[1] << endl;
			cout << 1 << endl;
			cout << A[1] << endl;
			return 0;
		}
		cout << A[1] << endl;
		cout << 2 << endl;
		cout << A[1] - 1 << spc << 1;
		return 0;
	}
	if(odd > 2) {
		cout << "Impossible";
		return 0;
	}

	bool fl = false;
	for(int i = 1; i <= m; i++) {
		if(!fl && A[i] % 2 == 1) {
			swap(A[i], A[1]);
			fl = true;
		}
		if(fl && A[i] % 2 == 1)
			swap(A[i], A[m]);
	}

	for(int i = 1; i <= m; i++)
		a[i] = A[i];
	if(a[1] < a[m])
		swap(a[1], a[m]);

	b[1] = a[1] - 1;
	b[m] = a[m] + 1; 
	for(int i = 2; i <= m - 1; i++)
		b[i] = a[i];
	for(int i = 1; i <= m; i++)
		cout << a[i] << spc;
	if(b[1] == 0) {
		cout << endl << m - 1 << endl;
		for(int i = 2; i <= m; i++)
			cout << b[i] << spc;
		return 0;
	}
	cout << endl << m << endl;
	for(int i = 1; i <= m; i++)
		cout << b[i] << spc;
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

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

        char[] c = s.toCharArray();
        String ans = "Good";
        for (int i = 1; i < c.length; i++) {
            if (c[i] == c[i - 1]) {
                ans = "Bad";
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;
  in(N);
  vector<int>B(N-1);
  ins(B);
  ull ans=B[0];
  up(i,1,N-2){
    ans+=min(B[i-1],B[i]);
  }
  ans+=B[N-2];
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, s, r[20000], i, j, res;
	while (cin >> n >> s, n && s)
	{
		for (i = 0; i < n; i++)
			cin >> r[i];
		for (i = res = 0; i < n-1; i++)
			for (j = i+1; j < n; j++)
				if (r[i]+r[j] > s)
					res++;
		cout << res << endl;
	}
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans=r/d-(l-1)/d;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
char n;
int a,b;
int main()
{
    cin>>a>>b;
    for(int s=0;s<a;s++)
    {
        cin>>n;
        if(n<'0'||n>'9') 
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cin>>n;
    if(n!='-')
    {
        cout<<"No"<<endl;
        return 0;

    }
    for(int s=0;s<b;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N,M;
    cin >> N;
    cin >> M;
    VLL A(N);
    priority_queue<ll> price;
    rep(i,N){
        cin >> A[i];
        price.push(A[i]);
    }
    rep(i,M){
        ll tmp=price.top();
        price.pop();
        tmp/=2;
        price.push(tmp);
    }
    ll ans=0;
    int L=price.size();
    rep(i, L){
        ans+=price.top();
        price.pop();
    }
    cout << ans << endl;
}

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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double pi = 3.1415926535897932;
  double H = h * 60 + m;
  
  cout << fixed << setprecision(15);
  
  
  cout << sqrt(a * a + b * b - 2 * a * b * cos((2 * pi * H / (double) 720) - (2 * pi * m / (double) 60))) << endl;
}


Measured memory_bytes: 4256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Vec fac, finv;

ll PowMod(ll a, ll n){
	if(n < 0) return PowMod(PowMod(a, -n), MOD-2);
	if(n == 0) return 1;
	if(n == 1) return a;
	if(n%2 == 0) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll inv(ll a){
	return PowMod(a, MOD - 2);
}

void init(ll n = 2e6){
	fac.resize(n+1);
	fac[0] = 1;
	repn(i, n) fac[i] = fac[i-1]*i%MOD;
	finv.resize(n+1);
	finv[n] = PowMod(fac[n], MOD-2);
	repr(i, n) finv[i] = finv[i+1]*(i+1)%MOD;
	finv[0] = 1;
}

ll combi(ll n, ll k){
	return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(void){
	init();
	ll n, m, k;
	cin >> n >> m >> k;

	ll sum = 0;
	ll ans = 1;
	ans *= combi(n * m - 2, k - 2);
	ans %= MOD;
	ll tmp = inv(6);
	tmp *= n - 1;
	tmp %= MOD;
	tmp *= n;
	tmp %= MOD;
	tmp *= n + 1;
	tmp %= MOD;
	ans *= tmp;
	ans %= MOD;
	ans *= m;
	ans %= MOD;
	ans *= m;
	ans %= MOD;
	sum += ans;
	ans = 1;
	ans *= combi(n * m - 2, k - 2);
	ans %= MOD;
	tmp = inv(6);
	tmp *= m - 1;
	tmp %= MOD;
	tmp *= m;
	tmp %= MOD;
	tmp *= m + 1;
	tmp %= MOD;
	ans *= tmp;
	ans %= MOD;
	ans *= n;
	ans %= MOD;
	ans *= n;
	ans %= MOD;
	sum += ans;
	sum %= MOD;

	co(sum);

	return 0;
}


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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    #define fast   ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;
    using namespace std;
    int dp[100005];
    bool dfs(int stones[], int k,int n)
    {
         //cout<<k<<" \n";
        if(k==0)
            return false;
       bool ans =false;
       if(dp[k]!=-1)
        return dp[k];
       for(int i=0; i<n; i++)
       {
           if(k-stones[i]>=0)
           {
                if(!dfs(stones, k-stones[i],n))
               {
                   ans = true;
                   break;
               }
           }

       }
      // cout<<k<<" "<<ans<<"\n";
       return dp[k]=ans;
    }
    int main()
    {
            fast
         int n,k;
         cin>>n>>k;
         int stones[n];
         for(int i=0; i<n; i++)
         {
             cin>>stones[i];
         }
         memset(dp,-1,sizeof(dp));
       if(dfs(stones, k,n))
        cout<<"First";
       else
        cout<<"Second";

        return 0;

    }



Measured memory_bytes: 8576
#include <stdio.h>
int main (){
int a,b,c,e,max=0,iga=0,i;
scanf ("%d%d%d%d",&a,&b,&c,&e);
  if (a>b && a>c){
  iga=b+c;
    max=a;
  }
  else if (b>a && b>c){
  iga=a+c;
    max=b;
  }
  else{
  iga=b+a;
    max=c;
  }
for (int i=0;i<e;i++){
  max=max*2;
}
	printf("%d",max+iga);
	return 0;
	}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const bool debug=false;
// const bool debug=true;
#define DEBUG if(debug==true)

int matrix[10][10];
bool fixed_[10][10];

long long dfs(int now,int n_team){
    int win=0,lose=0;
    vector<int> team;
    vector<int> wl;
    for(int i=1;i<now;i++){
        if(matrix[now][i]==1)win++;
        if(matrix[now][i]==-1)lose++;
    }
    for(int i=now+1;i<=n_team;i++){
        if(matrix[now][i]==1)win++;
        else if(matrix[now][i]==-1)lose++;
        else team.push_back(i);
    }
    DEBUG{
        printf("now : %d,win : %d, lose : %d\n",now,win,lose);
    }
    if(win>n_team/2||lose>n_team/2)return 0;
    if(now==n_team&&win==lose)return 1;
    else if(now==n_team&&win!=lose)return 0;
    while(win<n_team/2){
        wl.push_back(-1);
        win++;
    }
    while(lose<n_team/2){
        wl.push_back(1);
        lose++;
    }
    DEBUG{
        printf("wl size : %d, team size : %d\n",wl.size(), team.size());
    }
    long long res=0;
    do{
        for(int i=0;i<team.size();i++){
            matrix[team[i]][now]=wl[i];
        }
        res += dfs(now+1,n_team); 
    }while(next_permutation(wl.begin(),wl.end()));
    DEBUG{
        printf("res : %lld\n",res);
    }
    return res;
}

int main(void){
    while(true){
        int n,m;
        cin>>n;
        if(n==0)return 0;
        cin>>m;
        int tmp[2];
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                matrix[j][k]=0;
                fixed_[j][k]=false;
            }
        }
        for(int i=0;i<m;i++){
            cin >> tmp[0]>>tmp[1];
            matrix[tmp[0]][tmp[1]]=1;
            matrix[tmp[1]][tmp[0]]=-1;
            fixed_[tmp[0]][tmp[1]]=true;
            fixed_[tmp[1]][tmp[0]]=true;
        }
        long long res=dfs(1,n);
        cout << res << endl;
    }
}


Measured memory_bytes: 3152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC138B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] Ainput = Console.ReadLine().Split(' ');
            int[] A = new int[N];
            decimal bunbo = 0;
            for(int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Ainput[i]);
                bunbo += (decimal)1 / A[i];
            }
            Console.WriteLine(1 / bunbo);
        }
    }
}


Measured memory_bytes: 27528
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int m,n,a,b,i,j;
    scanf("%d %d",&a,&b);
    m=a;
    n=b;
     for(i=1;i<b;i++)

         m=m*10+a;

      for(j=1;j<a;j++)

        n=n*10+b;

     if(m>=n)

       printf("%d",m);


     else

       printf("%d",n);


}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	string s[10001];
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
		for(int j=i;j<n;j++)
			if(s[i]>s[j])swap(s[i],s[j]);
	for(int i=0;i<n;i++)
		cout<<s[i];
    return 0;
}



Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var k, x, start, end int
	fmt.Scan(&k)
	fmt.Scan(&x)
	if x-k+1 < -1000000 {
		start = -1000000
	} else {
		start = x - k + 1
	}
	if x+k-1 > 1000000 {
		end = 1000000
	} else {
		end = x + k - 1
	}
	for i := start; i <= end; i++ {
		fmt.Print(i)
		if i < end {
			fmt.Print(" ")
		}
	}
	fmt.Println("")

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("capastaty_input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	const int maxn = 1e5 + 5;

	int n, k;
	cin >> n >> k;

	set<int> s = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	while(k--){
		int x;
		cin >> x;
		s.erase(x);
	}

	vector<bool> flags(maxn);
	flags[0] = true;
	queue<int> Q;
	Q.push(0);

	while(!Q.empty()){
		int u = Q.front();Q.pop();

		if(u >= n){
			cout << u << endl;
			return 0;
		}

		for(auto &d : s){
			int v = u * 10 + d;
			if(!flags[v]){
				flags[v] = true;
				Q.push(v);
			}
		}
	}


	return 0;
}


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

int main() {
  double a; //入力値
  double b;
  double x; //aとbの平均値
  double n2;
  int n1;
  
  cin >> a >> b;
  x = (a + b)/2;
  n1 = x;
  n2 = x - n1;
  x = n1 + (n2*2);
  cout << x;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.trim().split(" ");
    var N = parseInt(input[0],10);
    var K = parseInt(input[1],10);
    var output = 0;
    for(var i = 1; i <= N; i++){
        var tmp = 1/N;
        for(var j = 0; j < 100000; j++){
            if(K <= i*Math.pow(2,j)){
                output += tmp;
                break;
            }
            else{
                tmp /= 2;
            }
        }
    }

    console.log(output);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX=1e6+10;
const ll mod=998244353;
int prime[MAX+100];
bool p[MAX+100];
int n,x,len;
ll a[MAX+100],f[MAX+100],ans,mu[MAX+100],s[MAX+100],inv[MAX+100];
void init()
{
	inv[0]=inv[1]=1;
	for (int i=2;i<=MAX;i++) inv[i]=(mod-mod/i)*(inv[mod%i])%mod;
	mu[1]=1;
	for (int i=2;i<=MAX;i++) 
	{
		if (!p[i]) {
			prime[++len]=i; mu[i]=-1;
		}
		for (int j=1;j<=len&&prime[j]*i<=MAX;j++)
		{
			p[prime[j]*i]=1;
            if (i%prime[j]==0) {
                mu[i*prime[j]]=0; break;
            }
            else mu[prime[j]*i]=-mu[i];
		} 
	}
	for (int i=1;i<=MAX;i++) 
		 {
		 	for (int j=1;j*i<=MAX;j++) s[i*j]=(s[i*j]+mu[i]*(ll)i%mod+mod)%mod;
		 }
}
int main()
{
	scanf("%d",&n);
	ans=0;
	for (int i=1;i<=n;i++) {
		scanf("%d",&x); a[x]++;
		ans=(ans-x+mod)%mod;
	}
	init();
	for (int i=1;i<=MAX;i++)
	{
		for (int j=1;j*i<=MAX;j++) f[i]=(f[i]+(ll)i*(ll)j%mod*a[i*j]%mod)%mod;
	}
    for (int i=1;i<=MAX;i++) f[i]=(f[i]*f[i]%mod*inv[i]%mod);
    for (int i=1;i<=MAX;i++) ans=(ans+s[i]*f[i]%mod)%mod;
    cout << ans*inv[2]%mod << endl;	
}

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


int main() {
  int n,m;
  cin >> n >> m;
  int a  = ( (n + m) * (n + m - 1) ) / 2;
  cout << a - (n * m);
};

Measured memory_bytes: 256
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    string s;
	cin >> s;
	ll a,b;
	rep(i,s.size()) if(s[i] == 'A') {a = i;break;}
	repr(i,s.size()) if(s[i] == 'Z') {b = i;break;}
	//cout << a << " " << b << endl;
	cout << b - a + 1 << endl;
	return 0;
}  


Measured memory_bytes: 640
import numpy as np

N = int(input())

A = [0] * N

for i in range(N):
    A[i] = int(input())

B = np.argsort(A)
A = np.sort(A)

for i in range(N):
    if i == B[N-1]:
        print(A[N-2])
    else:
        print(A[N-1])


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

using namespace std;

int main(){

  while(true){
    int w, d;
    cin >> w >> d;

    if(w == 0){
      break;
    }
    
    vector<int> h(w);
    for(int i = 0; i < w; i++){
      cin >> h[i];
    }

    vector<int> hd(d);
    for(int i = 0; i < d; i++){
      cin >> hd[i];
    }

    vector<int> cntW(21, 0);
    vector<int> cntD(21, 0);

    for(int temp: h){
      cntW[temp]++;
    }

    for(int temp: hd){
      cntD[temp]++;
    }

    int ans = 0;
    for(int i = 1; i <= 20; i++){
      int sum = cntW[i] + cntD[i];
      ans += min(cntW[i], cntD[i]) * i;
      ans += (sum - 2 * min(cntW[i], cntD[i])) * i;
    }

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



Measured memory_bytes: 2992
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable long mod = 10^^9 + 7;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    int x = chain(iota(1, n + 1), a).reduce!"a ^ b";
    int L = a.countUntil(x).to!int, R = a.retro().countUntil(x).to!int;

    auto c = Combination(n + 1, mod);

    foreach (k ; 1 .. n + 2) {
        long ans = c.binom(n + 1, k);

        if (k - 1 <= L + R) ans -= c.binom(L + R, k - 1);
        if (ans < 0) ans += mod;

        writeln(ans);
    }

}

struct Combination {
    int N;
    long mod;
    long[] fact, factinv;

    this (int N, long mod) {
        this.N = N;
        this.mod = mod;
        fact = new long[](N + 1);
        factinv = new long[](N + 1);
        fact[0] = factinv[0] = 1L;

        iota(1, N + 1).each!(i => (fact[i] = i * fact[i - 1] % mod));
        factinv[N] = powmod(fact[N], mod - 2, mod);
        iota(1, N).retro().each!(i => (factinv[i] = (i + 1) * factinv[i + 1] % mod));
    }

    long powmod(long x, long y, long mod) {
        return y > 0 ? powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1L;
    }

    long f(int n) {
        return fact[n];
    }

    long finv(int n) {
        return factinv[n];
    }

    long perm(int n, int k) {
        if (n < k) return 0L;
        return fact[n] * factinv[k] % mod;
    }

    long binom(int n, int k) {
        if (n < k) return 0L;
        return fact[n] * factinv[k] % mod * factinv[n - k] % mod;
    }

    long H(int n, int k) {
        if (n == 0 && k == 0) return 1L;
        return binom(n + k - 1, k);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main() {
	int N, T;
	cin >> N >> T;
	vector<vector<int>> DP(N, vector<int>(T + 1, 0));
	vector<pair<int,int>> AB(N);
	for (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;
	sort(AB.begin(), AB.end());
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= T; j++) {
			if (i == 0) {
				if (j <= T - AB[i].first) DP[i][j] = AB[i].second;
			}
			else {
				if (j + AB[i].first <= T) DP[i][j] = max(DP[i - 1][j], DP[i - 1][j + AB[i].first] + AB[i].second);
				else DP[i][j] = DP[i - 1][j];
				if (j == 0) DP[i][j] = max(DP[i - 1][0], DP[i - 1][1] + AB[i].second);
			}
		}
	}
	cout << DP[N - 1][0] << endl;
}


Measured memory_bytes: 38564
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<endl;}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  int n;cin>>n;
  if(n==1)cout<<"Hello World"<<endl;
  else {
    int a,b;cin>>a>>b;
    cout<<a+b<<endl;
  }
  return 0;
}

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

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;

int main(){

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

	string s, t;
	cin >> s >> t;
	t.pop_back();
	cout << (s == t ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int h = a[0], w = a[1];
		var s = new int[h].Select(_ => Console.ReadLine().Select(x => x == '#' ? -1 : 0).ToArray()).ToArray();

		for (int i = 0; i < h; i++)
		{
			var t = -1;
			for (int j = 0; j < w; j++)
			{
				if (s[i][j] == -1)
				{
					if (t != -1) for (int k = t; k < j; k++) s[i][k] += j - t;
					t = -1;
				}
				else if (t == -1) t = j;
			}
			if (t != -1) for (int k = t; k < w; k++) s[i][k] += w - t;
		}
		for (int j = 0; j < w; j++)
		{
			var t = -1;
			for (int i = 0; i < h; i++)
			{
				if (s[i][j] == -1)
				{
					if (t != -1) for (int k = t; k < i; k++) s[k][j] += i - t;
					t = -1;
				}
				else if (t == -1) t = i;
			}
			if (t != -1) for (int k = t; k < h; k++) s[k][j] += h - t;
		}
		Console.WriteLine(s.SelectMany(x => x).Max() - 1);
	}
}


Measured memory_bytes: 49720
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int L, A, B, C, D;
	int kokugo, sansuu;
	
	cin >> L >> A >> B >> C >> D;
	kokugo = (A + (C-1)) / C;
	sansuu = (B + (D-1)) / D;
	
	if (kokugo > sansuu)
	{
		cout << L - kokugo << endl;
	} else {
		cout << L - sansuu << endl;
	}
	
	//cout << "kokugo = " << kokugo << endl;
	//cout << "sansuu = " << sansuu << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}


int main() {
  int r;
  cin>>r;
  if(r<1200){cout<<"ABC"<<endl;}
  else if(r<2800){cout<<"ARC"<<endl;}
  else{cout<<"AGC"<<endl;}
  return 0;
}

Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

ll solve(vector<ll> & c , int k)
{
	vector<ll> chain = c;
	int l = chain.size();
	ll sum = chain[0];
	for(int i = 1;i<l;i++) sum+=chain[i];
	
	for(int i = 0;i<l-1;i++) chain.push_back(chain[i]);
	
	vector<ll> maxii(l+1 , -INF);
	
	for(int i = 1;i<chain.size();i++)
	{
		chain[i]+=chain[i-1];
	}
	
	for(int i = 0;i<l;i++)
	{
		for(int len = 1;len<=l;len++)
		{
			
			ll val = chain[i+len-1];
			if(i!=0) val-=chain[i-1];
			
			maxii[len] = max(maxii[len] , val); 		
		}	
	} 
	
	for(int i = 2;i<=l;i++)
	{
		maxii[i] = max(maxii[i] , maxii[i-1]);
	}
	
//	for(int i = 1;i<=l;i++)
//	{
//		cout<<maxii[i]<<" ";
//	}
//	cout<<endl;
	
	int rounds = k/l;
	
	if(rounds == 0)
	{
		return maxii[k];
	}
	else
	{
		if(sum <= 0) return maxii[l];
		
		ll val1 = maxii[l];
		ll val2 = (rounds-1)*sum+maxii[l];
		ll val3 = rounds*sum + maxii[k%l];
		
		return max(val1 , max(val2 , val3));
	}
}

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> per;
	vector<ll> val;
	
	for(int i = 0;i<n;i++)
	{
		int x;s(x);x--;
		per.push_back(x);	
	}
	
	for(int i = 0;i<n;i++)
	{
		ll x;cin>>x;
		val.push_back(x);	
	}
	
	vector<int> vis(n+1 , 0);
	
	ll maxi = -INF;
	for(int i = 0;i<n;i++)
	{
		if(vis[i]) continue;
		vector<ll> chain;
		vis[i] = 1;
		chain.push_back(val[i]);
		int cur = i;
		while(!vis[per[cur]])
		{
			cur = per[cur];
			vis[cur] = 1;
			chain.push_back(val[cur]);	
		}
		
		maxi = max(maxi , solve(chain , k));
	}
	
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 3816
N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))

time = 0
sum_t = sum(t)
velo_cap =[float("inf")]*(2*sum_t+1)
for i in range(N):
  start_t = time
  goal_t = time + 2*t[i]
  for s in range(0,2*sum_t+1):
    if s < start_t:
      velo_cap[s] = min(velo_cap[s],2*v[i]+(start_t-s))
    elif s<goal_t:
      velo_cap[s] = min(velo_cap[s],2*v[i])
    else:
      velo_cap[s] = min(velo_cap[s],2*v[i]+(s-goal_t))
  time += 2*t[i]
for s in range(2*sum_t+1):
  velo_cap[s] = min(velo_cap[s],2*sum_t-s,s)


print(sum(velo_cap)/4-(velo_cap[0]+velo_cap[-1])/8)


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

typedef long long LL;
#define MAXN 100000
#define _MOD 1000000009

int N;
LL C;

LL X[MAXN];
int V[MAXN];
LL rmx[MAXN];
LL lmx[MAXN];

int main() {
#ifdef OJ
    //freopen("input.txt", "rt", stdin);
    //    freopen("output.txt", "wt", stdout);
#endif
    std::ios_base::sync_with_stdio(false);

    cin >> N >> C;
    for (int i = 0; i < N; i++)
        cin >> X[i] >> V[i];

    LL cur = 0;
    for (int i = 0; i < N; i++) {
        cur += V[i];
        LL cost = cur - X[i];

        if (i == 0)
            rmx[i] = max(cost, 0LL);
        else
            rmx[i] = max(cost, rmx[i-1]);
    }

    cur = 0;
    for (int i = N-1; i >= 0; i--) {
        cur += V[i];
        LL cost = cur - (C -X[i]);

        if (i == N-1)
            lmx[i] = max(cost, 0LL);
        else
            lmx[i] = max(cost, lmx[i+1]);
    }

    LL ans = max(rmx[N-1], lmx[0]);
    //cout << rmx[N-1] << " " << lmx[0] << endl;

    cur = 0;
    for (int i = 0; i < N-1; i++) {
        cur += V[i];
        LL cost = cur - 2*X[i];
        ans = max(ans, cost + lmx[i+1]);
    }

    cur = 0;
    for (int i = N-1; i >= 1; i--) {
        cur += V[i];
        LL cost = cur - 2*(C-X[i]);
        ans = max(ans, cost + rmx[i-1]);
    }

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

Measured memory_bytes: 2944
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    return (0..n).map(|_| read()).collect();
}

fn main() {
    let mut x: usize = read();
    let mut y: usize = read();
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let mut pi: Vec<usize> = read_vec(a);
    let mut qi: Vec<usize> = read_vec(b);
    let mut ri: Vec<usize> = read_vec(c);
    pi.sort();
    qi.sort();
    ri.sort();

    // println!("{:?}", pi);
    // println!("{:?}", qi);
    // println!("{:?}", ri);

    let mut ans = 0;
    let mut eaten = 0;
    while x + y > eaten {
        let p;
        let q;
        let r;
        if x == 0 {
            p = 0;
        } else if pi.len() > 0 {
            p = *pi.last().unwrap();
        } else {
            p = 0;
        }
        if y == 0 {
            q = 0;
        } else if qi.len() > 0 {
            q = *qi.last().unwrap();
        } else {
            q = 0;
        }
        if ri.len() > 0 {
            r = *ri.last().unwrap();
        } else {
            r = 0;
        }
        // println!("{} {} {}", p, q, r);
        if p >= q && p >= r {
            pi.pop();
            ans += p;
            x -= 1;
        } else if q >= r {
            qi.pop();
            ans += q;
            y -= 1;
        } else {
            ri.pop();
            eaten += 1;
            ans += r;
        }
    }

    println!("{}", ans);
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("hard1.txt","r",stdin)
#define OUT freopen("hard1.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 1000005
#define FastIO  ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii ;

#define maxn 1000005
#define mod 1000000007LL
#define lim 1000000000
#define INF 4500000000000000000LL

bool f( int n , i64 c , i64 d , vector <i64> &v , i64 toMake )
{
    i64 tot = 0 ;
    for(int i=1; i<=n ; i++)
    {
        v.pb(d) ;
        tot += d;
    }
    if(tot < toMake) return false ;

    tot -= toMake ;

    int idx = -1 ;

    for(int i=n-1 ; i>=0 ; i--)
    {
        if( tot - 2*d >= 0 )
        {
            tot -= 2*d ;
            v[i] = -d ;
        }
        else{
            if( tot <= (d-c) || tot >= d+c )
            {
                v[i] -= tot ;
                return true ;
            }
            else{
                idx = i ;
                break ;
            }
        }
    }

    if( tot <= 1LL*(idx+1)*(d-c) )
    {
        for(int i=0 ; i<=idx && tot != 0 ; i++)
        {
            i64 ret = min(d-c,tot) ;
            tot -= ret ;
            v[i] -= ret ;
        }
        return true ;
    }
    v[idx] -= (d+c) ;
    tot -= (d+c) ;

    if( 1LL*(n-1-idx)*(d-c) + tot >= 0 )
    {
        for(int i=idx+1 ; i<n && tot!=0 ; i++)
        {
            i64 ret = min( -tot , d-c ) ;
            tot += ret ;
            v[i] += ret ;
        }
        return true ;
    }
    return false ;
}

i64 a[maxn] ;

int main()
{
    int n ;
    i64 A , B , C , D ;
    scanf("%d %lld %lld %lld %lld",&n,&A,&B,&C,&D) ;

    vector <i64> v ;

    bool res = f(n-1,C,D,v,abs(A-B)) ;

    if(!res) printf("NO\n") ;
    else
    {
        printf("YES\n") ;
   /*     a[1] = A ; a[n] = B ;
        for(int i=1 ; i<n ; i++) a[i+1] = a[i] + v[i-1] ;
        for(int i=1 ; i<=n ; i++) printf("%lld ",a[i]) ;
        printf("\n") ; */
    }

    return 0 ;
}


Measured memory_bytes: 6512
import           Data.Maybe                     ( fromMaybe )

mSimilarWithCoffee :: String -> Maybe Bool
mSimilarWithCoffee (_ : _ : c3 : c4 : c5 : c6 : _) =
    Just $ c3 == c4 && c5 == c6
mSimilarWithCoffee _ = Nothing


main = do
    s <- getLine
    let result = fromMaybe False $ mSimilarWithCoffee s
    case result of
        True  -> putStrLn "Yes"
        False -> putStrLn "No"


Measured memory_bytes: 380
/*
    Problem 18
    https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_4_B
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int MAX = (1e+5) + 5;
/* global variables */
vector<int> v(MAX);
int n;
/* function */
bool binSearch(int x) {
    int r = 0, l = n;
    int mid;
    while (r < l) {
        mid = (r + l) / 2;
        if (x == v[mid]) return true;
        else if (x < v[mid]) l = mid;
        else r = mid + 1;
    }
    return false;
}
/* main */
int main(){
    int q, target;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> v[i];
    cin >> q;
    int cnt = 0;
    for (int i = 0; i < q; i++) {
        cin >> target;
        if (binSearch(target)) cnt++;
    }
    cout << cnt << '\n';
}



Measured memory_bytes: 3092
import sys
N = int(input())
A = list(map(int,input().split()))
c = 1

for i in range(N):
    if A[i] == 0:
        print(0)
        sys.exit()

for i in range(N):
    c *= A[i]
    if c > 10**18:
        print(-1)
        sys.exit()
print(c)

Measured memory_bytes: 84580
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin>>n;
  int cnt = 1;
  int t;cin>>t;
  int max_v = t;
  int min_v = t;
  for(int i=1;i<n;++i){
    cin>>t;
    if(t>max_v){
      max_v = t;
    } else {
      if(t<min_v){
        min_v = t;
        ++cnt;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

const int N = 55;

string s[N+5];
int tim[N+5];
int n;

int main(){
	scanf("%d",&n);
	int tot = 0;
	for(int i=1;i<=n;i++){
		cin >> s[i] >> tim[i];
		tot+=tim[i];
	}
	string cari;
	cin >> cari;
	for(int i=1;i<=n;i++){
		tot-=tim[i];
		if(s[i] == cari){
			break;
		}
	}
	cout << tot << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c;
  if(a>b){
    d = a;
    a = b;
    b = d;
  }
  if(b>c){
    d = b;
    b = c;
    c = d;
  }
  if(a>b){
    d = a;
    a = b;
    b = d;
  }
  cout << a <<" "<< b <<" "<< c <<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& it : a)
        cin >> it;
    sort(a.rbegin(), a.rend());
    ll ans = a[0];
    int cnt = n - 2;
    for (int i = 1, g = 0; g < cnt; i++) {
        int x = min(2, cnt - g);
        ans += x * a[i];
        g += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4000
n = int(input())
s = []
ss = []
count = 0

for i in range(n):
    s.append(input())


for i in range(n-1):
  if s[i][-1] != s[i+1][0]:
    count = 1
    break

s.sort()
for i in range(n-1):
  if s[i] == s[i+1]:
    count = 1

if count == 1:
  print("No")
else:
  print("Yes")
  

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 int MOD = 1000000007;

string pad(int n) {
    
}
int main() {
    int n, m;
    cin >> n >> m;
    map<int, vector<pair<int, int>>> a;
    int p, y;
    REP1(i, m) {
        cin >> p >> y;
        a[p].push_back(make_pair(y, i));
    }
    set<tuple<int, int, int>> s;
    for (auto x : a) {
        vector<pair<int, int>> y = x.second;
        sort(ALL(y));

        int idx = 1;
        for (auto z : y) {
            s.emplace(z.second, x.first, idx++);
        }
    }

    for (auto t : s) {
        cout << setfill('0') << right << setw(6) << get<1>(t);
        cout << setfill('0') << right << setw(6) << get<2>(t) << endl;
    }
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
inline bool chmin (int& a, int b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> grh(n);
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		grh[s].push_back(t);
		grh[t].push_back(s);
	}
	int tmr = 0;
	vector<int> ord(n, -1), low(n, -1);
	vector<pair<int, int>> bdg;
	function<void(int, int)> dfs = [&] (
		int crr
	,	int prt
	) {
		ord[crr] = low[crr] = tmr++;
		for (int nxt : grh[crr]) {
			if (ord[nxt] == -1) dfs(nxt, crr);
			if (nxt != prt) chmin(low[crr], low[nxt]);
			if (ord[crr] < low[nxt]) bdg.emplace_back(crr, nxt);
		}
	};
	dfs(0, 0);
	for (auto it = bdg.begin(); it != bdg.end(); it++) {
		if (it->first > it->second) swap(it->first, it->second);
	}
	sort(bdg.begin(), bdg.end());
	for (auto it = bdg.begin(); it != bdg.end(); it++) {
		cout << it->first << ' ' << it->second << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define IO ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
using namespace std;

int main()
{
	IO
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a == c-b)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[], int n, int key) {
	int i=0;
	A[n] = key;
	while(A[i] != key) i++;
	return i!= n;
}

int main() {
	int i, n, A[10000+1], q, key, sum = 0;
	
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &A[i]);
	
	scanf("%d", &q);
	for(i=0; i<q; i++) {
		scanf("%d",&key);
		if(search(A, n, key)) sum++;
	}
	printf("%d\n", sum);
	
	return 0;
	
}

Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;

  while( cin >> n, n){
    string msg[1000];
    int pos[1000];
    for(int i = 0; i < n; i++){
      cin >> msg[i];
      pos[i] = msg[i].rfind('.');
    }

    for(int i = 0; i < n; i++){
      if(pos[i] != string::npos){
        msg[i][pos[i]] = '+';
      }
    }

    for(int i = 0; i < n; i++){
      if(pos[i] != string::npos){
        int j = i + 1;
        while(j < n && pos[i] < pos[j]) j++;
        if(j != n && pos[i] == pos[j]){
          for(int k = i + 1; k < j; k++) msg[k][pos[i]] = '|';
        }
      }
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < msg[i].size(); j++){
        if(msg[i][j] == '.') msg[i][j] = ' ';
      }
      cout << msg[i] << endl;
    }

  }

  return 0;

}

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

using namespace std;

int main(void)
{
	char c[15];
	string s;
	cin >> s;
	int ind=0;
	for(int i=1;i<=s.size();i++)
	{
		if(s[i-1]=='B')
			ind=max(ind-1,0);
		else
		{
			ind++;
			c[ind-1]=s[i-1];
		}
	}
	for(int i=1;i<=ind;i++)
		cout << c[i-1];
	cout << endl;
}

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

int main() {
	string a;
	cin >> a;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == ',') {
			a[i] = ' ';
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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 int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

map<ll, int> factorize(ll n) {
  map<ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

  ll a, b;
  cin >> a >> b;
  ll c = gcd(a, b);

  auto mp = factorize(c);  // a, b の gcd を素因数分解
  ll ans = mp.size() + 1;   // +1 は 1 のぶん

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var s string
	fmt.Fscan(read, &s)

	for i := 0; i < len(s); i++ {
		fmt.Print("x")
	}
	fmt.Println("")

}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
  int n,d,ans=0,x[200001],y[200001];
  float a;
  cin>>n>>d;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    if(d>=hypot(x[i],y[i])) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5192