akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define maxn 200001
 
#define ll long long int
 vector<int> wav;
 int m;vector<int> q;
 //int dp[22][11][1002]
 
int main(){
	int n;
	double d;
	cin>>n>>d;
	int ans=0;
	for(int i=0;i<n;i++){
		double a,b;
		cin>>a>>b;
		
		double dist=sqrt(a*a +b*b);
		if(dist<=d){
			ans++;
		}
	}
	cout<<ans<<endl;
 
}


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

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(int i = first; i <= to; ++i)
#define MyDebug

#ifdef MyDebug
	#define debug(x) cout << #x << " : " << x << endl
	#define debugP(x) cout << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

int a[20], s[(int)pow(2, 20)];
int m[200];
int n, q;
int j = 0;

bool dfs(int i, int s1) {
	if (i == n) {
		s[j++] = s1;
		//cout << s1 << endl;
		return false;
	}
	if (dfs(i + 1, s1 + a[i])) return false;
	if (dfs(i + 1, s1)) return false;
	return false;
}

void solve() {
	cin >> n;
	rep(i, 0, n) {
		cin >> a[i];
	}
	cin >> q;
	rep(i, 0, q) {
		cin >> m[i];
	}
	dfs(0, 0);
	bool isOk;
	sort(s, s + (int)pow(2, n));
	rep(k, 0, q) { 
		if (binary_search(s, s + (int)pow(2, n), m[k])) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 7404
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;
ll inf = 1e16;
int main(){
  ll i,j,k,n,m;
  string s;
  cin >> n >> m;
  vector<vector<pair<ll,ll> > > vi(n+1);
  long long v[n+1][n+1];
  for(i=0;i<=n;i++)for(j=0;j<=n;j++)v[i][j]=inf;
  for(i=0;i<n;i++)v[i][i]=0;
  for(i=0;i<m;i++){
    ll a,b,c;
    cin >> a >> b >> c;
    vi[a-1].push_back(make_pair(b-1,c));
    v[a-1][b-1]=c;
    v[b-1][a-1]=c;
  }
  for(k=0;k<n;++k){
    for(i=0;i<n;++i){
      for(j=0;j<n;++j){
        if(v[i][k]!=inf && v[k][j]!=inf){
          v[i][j] = min(v[i][j],v[i][k]+v[k][j]);
        }
      }
    }
  }
  ll cnt=0;
  int w;
  for(i=0;i<n;i++){
    for(w=0;w<vi[i].size();w++){
      bool ch = true;
      for(j=0;j<n;j++){
        for(k=0;k<n;k++){
          if(v[j][k]==v[j][i]+v[vi[i][w].first][k]+vi[i][w].second)ch=false;
        }
      }
      if(ch)cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	int S;
	cin >> S;
	int h;
	int a;
	int m;
	int s;
	h = S / 3600;
	a = S - h * 3600;
	m = a / 60;
	s = a - 60 * m;
	cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int LL
#define lowbit(i) ((i)&(-(i)))
using namespace std;
typedef long long LL;
const int MAX_N=200005;
int bit[MAX_N];
int c[MAX_N];
int h[MAX_N];
int a[MAX_N];
int dp[MAX_N];
int n;
void modify(int i,int x)
{
	c[i]=x;
	while(i<=n)
	{
		bit[i]=c[i];
		for(int j=1;j<lowbit(i);j*=2)bit[i]=max(bit[i],bit[i-j]);
		i+=lowbit(i);
	}
}
int query(int l,int r)
{
	int ans=c[r];
	while(true)
	{
		ans=max(ans,c[r]);
		if(r==l)break;
		r--;
		while(r-l>=lowbit(r))
		{
			ans=max(ans,bit[r]);
			r-=lowbit(r);
		}
	}
	return ans;
}
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		int rec=query(1,h[i]);
	/*	int rec=0;
		for(int j=1;j<i;j++)
		{
			if(h[j]<h[i])rec=max(rec,dp[j]);
		}*/
		dp[i]=rec+a[i];
		modify(h[i],dp[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    int f_x = 0;
    int cn = n;
    while(cn != 0) {
        f_x += cn % 10;
        cn /= 10;
    }
    cout << ((n % f_x == 0)?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    int p = 0;
    cin >> s;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'p') p++;
    }
    cout << s.size() / 2 - p << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int sum=0,tmp;
  for(int i=0;i<m;i++){
    cin>>tmp;
    sum+=tmp;
  }
  int val = n-sum;
  if(val<0){
    cout<<-1<<endl;
  }else{
    cout<<val<<endl;
  }
  return 0;
}

Measured memory_bytes: 3604
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
t = [int(i) for i in input().split()] # 配列で数字

m = int(input())
drink = []
for _ in range(m):
    p, x = map(int, input().split())
    drink.append((p, x))

for p, x in drink:
    ans = 0
    for j in range(n):
        if p - 1 == j:
            ans += x
        else:
            ans += t[j]
    print(ans)

Measured memory_bytes: 38564
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	a := make(map[int]int)
	for i := 0; i < N; i++ {
		x := getInt()
		a[x]++
	}

	ans := 0
	for i, v := range a {
		if i != v {
			if i > v {
				ans += v
			} else {
				ans += v - i
			}
		}
	}
	out(ans)
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b; cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int N;
    cin>>N;

    vector <int> a(N+2,0);//数列入力
    a[0]=0;
    a[N+1]=0;
    for(int i=1;i<N+1;i++){
        cin>>a[i];
    }
    int max=0;//最大値
    int min=0;//最小値

    /*for(int j=0;j<N+2;j++){//最大値最小値の入力
        if(max<a[j]){
            max=a[j];
        }
        if(min>a[j]){
            min=a[j];
        }
    }*/   
    int money=0;//そう移動距離
    for(int k=0;k<N+1;k++){
        money+=abs(a[k+1]-a[k]);
    }
    
    for(int l=0;l<N;l++){
    if(a[l]<=a[l+1]&&a[l+1]<=a[l+2]){
         cout<<money<<endl;
    }else if(a[l]>=a[l+1]&&a[l+1]>=a[l+2]){
        cout<<money<<endl;
    }else if(a[l]<a[l+1]&&a[l+1]>a[l+2]){
         if(a[l+2]<a[l]){
         cout<<money-2*abs(a[l]-a[l+1])<<endl;
        }else{
         cout<<money-2*abs(a[l+1]-a[l+2])<<endl;
        }
    }else if(a[l]>a[l+1]&&a[l+1]<a[l+2]){
        if(a[l+2]>a[l]){
         cout<<money-2*abs(a[l]-a[l+1])<<endl;
        }else{
         cout<<money-2*abs(a[l+1]-a[l+2])<<endl;
        }
    }
    
    }
    return 0;
}

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

using namespace std;

using ll = long long;

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

size_t a[2][2019];

void solve() {
    size_t n, m, x;
    cin >> n >> m >> x;
    vector<vector<size_t>> a(n);
    vector<size_t> c(n);
    size_t ans = INF;
    REP(j, n) {
        cin >> c.at(j);
        REP(i, m) {
            size_t tmp;
            cin >> tmp;
            a.at(j).push_back(tmp);
        }
    }
    REP(i, 1 << n) {
        bitset<16> bit(i);
        size_t cost = 0;
        vector<size_t> r(m);
        REP(j, n) {
            if (bit[j]) {
                cost += c.at(j);
                REP(l, m) {
                    r.at(l) += a.at(j).at(l);
                }
            }
        }
        if (cost < ans) {
            bool ok = true;
            REP(l, m) {
                if (r.at(l) < x) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                ans = cost;
            }
        }
    }
    if (ans == INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3656
#include<iostream>

int main() {
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;

    bool result1 = ( x + r > 0 && y + r > 0 );
    bool result2 = ( x + r <= W && y + r <= H );

    if ( result1 == 1 && result2 == 1 ) {      
        std::cout << "Yes" << "\n";
    } else {
        std::cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

  private static int partition(int[] array, int p, int r) {
    int pivot = array[r];
    int i = p - 1;
    int j = p;

    while (j < r) {
      if (array[j] <= pivot) {
        i++;
        swap(array, i, j); 
      }   
      j++;
    }   
    swap(array, i + 1, r); 

    return i + 1;
  }

  private static void swap(int[] array, int i, int j) {
    int tmp = array[j];
    array[j] = array[i];
    array[i] = tmp;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str = scan.next();

    //String[] parsed = args[0].split("\n");
    int N = Integer.valueOf(str);
    //System.out.println(N);

    //String input = parsed[1];
    int[] array = new int[N];
    for (int i = 0; i < N; i++) {
      array[i] = scan.nextInt();
      //System.out.println(array[i]);
    }   

    int part = partition(array, 0, array.length - 1); 

    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < N; i++) {
      if (i == part) {
        builder.append("[" + array[i] + "]");
      } else {
        builder.append(array[i]);
      }   
      builder.append(" ");
    }   
    System.out.println(builder.toString().trim());

  }
}

Measured memory_bytes: 68548
////////////////////////////////////
///     Please Give Me AC!!!     ///
////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    ll a, b, c, d; cin>> a >> b >> c >> d;

    ll ans = -2e+9;
    ll e = a * c;
    ll f = a * d;
    ans = max(e, f);
    ll g = b * c;
    ans = max(ans, g);
    ll h = b * d;
    ans = max(ans, h);
    cout<< ans << endl;
}


Measured memory_bytes: 3680
use std::cmp::min;
use std::iter::Iterator;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = 999;
    let l = 3;
    for i in 0..(s.len() - l + 1) {
        let t: String = s.chars().skip(i).take(l).collect();
        let x: i32 = t.parse().unwrap();
        ans = min(ans, (x - 753).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;

    string S;
    
    cin >> S;

    S = S + "+++++";
    ll cnt = 0;
    rep(ni,N){
        stmp = S.substr(ni,3);
        if(stmp=="ABC"){
            cnt++;
        }
    }
    cout << cnt << endl;

    

}

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

int N,M,Q;
int maxans=0;
  int A[51];
  int B[51];
  int C[51];
  int D[51];

void dfs(vector<int>X){
  if(X.size()==N+1){
    int temp=0;
    for(int k=0;k<Q;k++){
      if(X[B[k]]-X[A[k]]==C[k]) temp+=D[k];
    }
    maxans=max(maxans,temp);
  return;
  }
  X.push_back(X.back());
  while(X.back()<=M){
    dfs(X);
    X.back()++;
  }
}


int main(){

  cin>>N>>M>>Q;

  for(int i=0;i<Q;i++){
    cin>>A[i]>>B[i]>>C[i]>>D[i];
  }
  dfs(vector<int>(1,1));
  cout<<maxans<<endl;
    
  return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;

    int N = S.length();
    int M = T.length();
    for (int i = N - M; i >= 0; i--) {
        string s = S.substr(i, M);
        bool ok = true;
        for (int j = 0; j < M; j++) {
            if (s[j] != '?' && s[j] != T[j]) {
                ok = false;
            }
        }
        if (ok) {
            string ans = S.substr(0, i) + T + S.substr(i + M);
            for (auto& c : ans) {
                if (c == '?') {
                    c = 'a';
                }
            }
            cout << ans << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;
}


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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll N_MAX = 100000;
const ll K_MAX = 100000;

ll N, K;

void input() {
	scanf("%lld%lld", &N, &K);
}

void solve() {
	double ans = 0.0;

	repeq(i,N){
		if(K<=i){
			ans+=(1.0/N);
			continue;
		}
		double x=1.0;
		ll j=i;
		while(j<K){
			j*=2;
			x*=0.5;
		}
		ans+=(1.0/N)*x;
		debug(x);
		debug(K);
		debug((1.0/N)*x);
	}




	printf("%.12lf\n",ans);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				push_back(z)
#define ff					/first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}

void start(){
      #ifndef ONLINE_JUDGE 
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}

void solve()
{
 	ll n;cin>>n;
 	ll a[n+3];
 	for(int i=0;i<n-1;i++){
 		cin>>a[i];
	 }
	 vector<ll>v;
	 v.pb(a[n-2]);
	 for(int i=n-2;i>=1;i--){
	 	if(a[i-1]<a[i]){
	 		v.pb(a[i-1]);
		 }
		 else{
		 	v.pb(a[i]);
		 }
	 }
	 v.pb(a[0]);
	 ll s=0;
	 for(int i=0;i<sz(v);i++){
	 	s+=v[i];
	 }
	 cout << s << nl;
}

int main(){
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";

		  solve();
	//}
	
	return 0;
}


Measured memory_bytes: 3564
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
-- import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import GHC.Magic (oneShot)


main :: IO ()
main = do
  n <- read <$> getLine
  ls <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  print $ binSearch ls 0 n

{-# INLINE binSearch #-}
binSearch :: VU.Vector Int -> Int -> Int -> Int
binSearch !ls = go
  where
    go ng ok | ok - ng <= 1          = ok
             | isPossibleWith mid ls = go ng  mid
             | otherwise             = go mid ok
      where
        mid = (ok + ng) `shiftR` 1

{-# INLINE isPossibleWith #-}
isPossibleWith :: Int -> VU.Vector Int -> Bool
isPossibleWith 1 !ls = VU.and $ VU.zipWith (<) ls (VU.tail ls)
isPossibleWith numChars !ls
  = VU.foldr loop (\ !len_ !chars_ -> True) ls 0 Nil
  where
    {-# INLINE loop #-}
    loop = \ !reqLen cont -> oneShot $ \ !wordLen !chars ->
      if reqLen > wordLen
      then cont reqLen chars
      else countUpCps (cont reqLen) numChars (cutOff chars reqLen) (reqLen-1) 

data List = Nil | Snoc !List {-# UNPACK #-} !Int {-# UNPACK #-} !Int
 deriving Show

-- assumes numChars > 1
{-# INLINE countUpCps #-}
countUpCps :: (List -> Bool) -> Int -> List -> Int -> Bool
countUpCps cont !numChars = go
  where
    go !xs !ind | ind < 0 = False
    go (Snoc xs i e) ind | i == ind = if | e >= numChars - 1 -> go xs (ind-1)
                                         | otherwise -> cont $! Snoc xs i (e+1)
    go xs ind = cont $! Snoc xs ind 1

{-# INLINE cutOff #-}
cutOff :: List -> Int -> List
cutOff !xs !till = go xs
  where
    go (Snoc xs i e) | i >= till = go xs
    go xs = xs


Measured memory_bytes: 7036
// Akshit Awasthi
#include <bits/stdc++.h>
#define int long long
#define float long double
#define ar array
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(x) x.begin(), x.end()
#define deb(...) cerr << "[" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "]\n"
#define deb2(x, y) cerr << #x << " = " << x << "\t" << #y << " = " << y << endl
#define fastio                    \
    std::ios::sync_with_stdio(0); \
    std::cin.tie(NULL);           \
    std::cout.tie(NULL)
#define mod1 1000000007
#define mod2 998244353
#define mod mod1
#define MAX 200015
using namespace std;

template <class T>
istream& operator>>(istream& stream, vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream >> v[i];
    return stream;
}
template <class T1, class T2>
istream& operator>>(istream& stream, pair<T1, T2>& p) {
    return stream >> p.first >> p.second;
}
template <class T>
ostream& operator<<(ostream& stream, const vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream << v[i] << ' ';
    stream << '\n';
    return stream;
}
template <class T1, class T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& pair) {
    return stream << pair.first << ' ' << pair.second;
}
int pow(int a, int n) {
    if (n < 0) return 0;
    int ans = 1;
    while (n) {
        if (n & 1) ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int __lcm(int a, int b) { return (a / __gcd(a, b)) * b; }
int fact(int n) { return n == 0 ? 1LL : n * fact(n - 1) % mod; }
int inverse(int x, int p = mod) { return pow(x, p - 2); }
int nck(int n, int k, int p = mod) {
    return fact(n) * inverse(fact(k), p) % p * inverse(fact(n - k)) % p;
}

vector<int> arr;

void solve(void) {
    int n, d;
    cin >> n >> d;
    int x, y;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            ++ans;
        }
    }
    cout << ans << '\n';
}

int32_t main(void) {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    fastio;
    // cout.setf(std::ios::unitbuf);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
//in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
int arr[1000] ;
int main ()
{
	int n , ans = 0;
	cin >> n ;
	n *= 2 ; 
	for ( int i = 0 ;i < n ; i++ ) 
		cin >> arr[i];
	sort ( arr, arr+n ) ;
	for ( int i = 0 ; i < n ; i+= 2 ) 
		ans += min ( arr[i] , arr[i+1] ) ;
	cout << ans << endl;
}

Measured memory_bytes: 764
s = STDIN.gets.strip

expressions = []

0.upto(2**(s.size - 1) - 1) do |i|
  expression = ''
  0.upto(s.size - 1) do |j|
    if ((1&i >> j) == 1)
      expression += "#{s[j]}+"
    else
      expression += s[j]
    end
  end

  expressions << expression
end

answer = expressions.reduce(0) do |sum, expression|
  sum + expression.split('+').map(&:to_i).reduce(&:+)
end

puts answer

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

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

    vector<int> arr(n);
    for(int i = 0 ; i < n ; i++)
    cin>>arr[i];

    long long ans = 0;

    for(int i = 0 ; i < n-1 ; i++) {
        if(arr[i+1] < arr[i]) {
            ans += arr[i] - arr[i+1];
            arr[i+1] += arr[i] - arr[i+1];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3952
#include<stdio.h>

int main(void){
    int a=0,b=0;
    int sq=0,leng=0;
    scanf("%d %d",&a,&b);
    sq = a*b;
    leng = (a*2)+(b*2);
    printf("%d %d\n",sq,leng);
    return 0;

}

Measured memory_bytes: 1796
#include<iostream>
#include<algorithm>
using namespace std;
int dp[101][10001];
int main(){
  int n,W;
  int v[100],w[100];
  cin>>n>>W;
  for(int i=1;i<=n;i++){
    cin>>v[i]>>w[i];
  }
  
  for(int i=0;i<=W;i++){
    dp[0][i]=0;
  }
  for(int i=0;i<=n;i++){
    dp[i][0]=0;
  }
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=W;j++){
      if(j>=w[i]){
	dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      }else{
	dp[i][j]=dp[i-1][j];
      }
    }
  }
  cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 5108
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		long a = in.nextLong();
		long b = in.nextLong();
		System.out.println(solve(a, b));
		in.close();
	}

	private static long solve(long a, long b) {
		long x = lcm(a, b);
		long r = 0;
		long t = (long) (Math.sqrt(x) + 1);
		for (long i = 2; i <= t; i++)
			if (x % i == 0) {
//				System.out.println(i+" "+x);
				r++;
				while (x % i == 0)
					x /= i;
				t = (long) (Math.sqrt(x) + 1);
			}
		if (x != 1)
			r += 2;
		else
			r++;
		return r;
	}

	private static long lcm(long a, long b) {
		if (a > b) {
			long t = a;
			a = b;
			b = t;
		}
		if (b % a == 0)
			return a;
		return lcm(a, b % a);
	}
}


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

int main() {
	long long w,h,x,y;cin>>w>>h>>x>>y;
	double ans=double(w*h)/2;
	int ans2=0;
	if(2*x==w){
		if(2*y==h){
			ans2=1;
		}
	}
	cout<<ans<<' '<<ans2<<endl;

	return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 998244353; //1e9+7;
const int MAXN = 1e7+1;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> red(A), green(B), colorless(C);
    fori(i,A) cin >> red[i];
    fori(i,B) cin >> green[i];
    fori(i,C) cin >> colorless[i];

    sort(all(red));
    reverse(all(red));

    sort(all(green));
    reverse(all(green));

    sort(all(colorless));
    reverse(all(colorless));

    multiset<int> pq;
    for(int i = 0; i < min((int)red.size(),X); i++) pq.insert(red[i]);
    for(int i = 0; i < min((int)green.size(),Y); i++) pq.insert(green[i]);
    int c = 0;
    for(int i = red.size(); i < X && c < colorless.size(); i++) pq.insert(colorless[c++]);
    for(int i = green.size(); i < Y && c < colorless.size(); i++) pq.insert(colorless[c++]);

    while(c < colorless.size()) {
        auto mn = pq.begin();
        if(*mn >= colorless[c]) break;
        pq.erase(mn);
        pq.insert(colorless[c++]);
    }

    LL ans = 0;
    for(auto it: pq) ans += it;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9856
#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 main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 1e5 + 7;
const int inf =  1e9 + 7;

vector< pii > G[maxn];
int dist[maxn];
priority_queue< pii > Q;

int main() {
	int k; sd(k);
	for (int j = 0; j < k; j++) {
		for (int d = 0; d <= 9; d++) {
			G[j].pb(mp( (j * 10 + d)%k, d));
		}
	}
	for (int d = 1; d <= 9; d++) {
		G[k].pb(mp(d % k, d));
	}

	fill(dist, dist + maxn, inf);
	dist[k] = 0; 
	Q = *new priority_queue< pii> (); Q.push(mp(0, k));

	while (Q.size() > 0) {
		int v = Q.top().second, old = Q.top().first; Q.pop();
		if (old > dist[v]) continue;

		for (int j = 0; j < G[v].size(); j++) {
			int y = G[v][j].first, c = G[v][j].second;
			if (dist[y] > dist[v] + c) {
				dist[y] = dist[v] + c;
				Q.push(mp(-dist[y], y));
			}
		}
	}

	pd(dist[0]); endc;
}


Measured memory_bytes: 19188
n = int(input())
test = 1
arr = [int(i) for i in input().split()]
for i in range(n):
    if arr[i] == test:
        # print(i)
        test += 1
if n == 1 and test == 1:
    print(0)
elif test == 1:
    print(-1)
else:
    print(n - test + 1)


Measured memory_bytes: 25768
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};


int main(){
    Stream io;

    int N;
    io.read(N);
    cout << (1000 - N % 1000) % 1000;

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   VEC(int,v,3);
  sort(ALL(v));
   cout<<(v[1]==v[0]?v[2]:v[0]);
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////


int main(){
    int n;cin>>n;
    vector<int>ans;
    int count=1;
    if(n==3){
        ans.pb(2);ans.pb(5);ans.pb(63);
    }else if(n>=19999){
        int pos=1;
        while(count<=n){
            if(pos%2==0||pos%3==0){ans.pb(pos);count++;}
            pos++;
        }
    }else{
        int pos=7;
        ll sum=0;
        while(count<=n-2){
            if(pos%2==0||pos%3==0){
                ans.pb(pos);
                count++;
                sum+=pos%6;
            }
            pos++;
        }
        int k=sum%6;
        int perm[4]={2,3,4,6};
        do{
            if((k+perm[0]+perm[1])%6==0){
                ans.pb(perm[0]);ans.pb(perm[1]);
                break;
            }
        }while(next_permutation(perm,perm+4));
    }
    for(auto x:ans)cout<<x<<" ";cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <queue>
#include <unordered_map>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>

using namespace std;

bool isSubsequence(string s, string t);

int main() {

    int n = 0;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    cout << arr[n/2] - arr[(n / 2) - 1];

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
auto max(int a, int b) {
	if (a < b) {
		swap(a, b);
	}
	return a;
}

int g[15][15];

int main() {

	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

signed main() {
    int x, n;
    set<int> p;
    cin>>x>>n;
    rep(i,n) {
        int k;
        cin>>k;
        p.insert(k);
    }
    int b = 0;
    while(true) {
        if (p.find(x - b) == p.end()) {
            cout<<(x-b);
            return 0;
        }
        if (p.find(x + b) == p.end()) {
            cout<<(x+b);
            return 0;
        }
        b++;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int L, R;

int main() {
  ios_base::sync_with_stdio(false);
  cin >> L >> R;
  int ans = 2019;
  for(int i = L; i <= min(R, L + 2018); i++) {
    for(int j = i + 1; j <= min(R, L + 2018); j++) {
      ans = min(ans, (i % 2019) * (j % 2019) % 2019);
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	
	ll a, b;
	string s;
	cin >> a >> b >> s;
	
	bool ans = true;
	rep(i, a + b + 1) {
		if (i == a && s[i] != '-') ans = false;
		else if (i != a && s[i] < '0' || '9' < s[i]) ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int f[1000010],a[1000010],p[1000010],vis[1000010],b[1000010],ok=1,n;
int gcd(int x,int y)
{
    if(y==0) return x;
    return gcd(y,x%y);
} 
int main()
{
    int i,t1,t2,j;
    cin>>n;
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=2;i<=1000000;i++)
    {
         if(vis[i]==0)
         {
             p[i]=1;
             f[i]=i;
             for(j=1;i*j<=1000000;j++)
             {
                  if(f[i*j]==0) f[i*j]=i;
                  vis[i*j]=1;
             }
         }
    }
    for(i=1;i<=n;i++)
    {
        t1=a[i];
        t2=0;
        while(t1>1)
        {
            if(f[t1]!=t2) b[f[t1]]++;
            t2=f[t1];
            t1=t1/f[t1];
        }
    }
    for(i=1;i<=1000000;i++) if(b[i]>1) ok=0;
    if(ok==1) 
    {
        cout<<"pairwise coprime";
        return 0;
    }
    t1=a[1];
    for(i=1;i<=n;i++) t1=gcd(t1,a[i]);
    if(t1==1)
    {
        cout<<"setwise coprime";
        return 0;
    }
    cout<<"not coprime";
}
               
               
     


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W, Ch, Cw, Dh, Dw;
char S[1005][1005];
int Dist[1005][1005];

int di[4] = {-1,0,1,0}, dj[4] = {0,-1,0,1};

int main(){
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  fill((int*)Dist, (int*)(Dist + H), -1);

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++) cin >> S[i][j];
  }

  priority_queue <pair<int,Pii>, vector<pair<int,Pii>>, greater<pair<int,Pii>>> que;
  que.push({0, {Ch-1, Cw-1}});

  while (!que.empty()){
    pair<int, Pii> Q = que.top(); que.pop();
    if (Dist[Q.se.fi][Q.se.se] != -1) continue;
    Dist[Q.se.fi][Q.se.se] = Q.fi;
    for (int k = 0; k < 4; k++){
      int I = Q.se.fi + di[k], J = Q.se.se + dj[k];
      if (0 <= I && I < H && 0 <= J && J < W){
        if (Dist[I][J] == -1 && S[I][J] == '.'){
          que.push({Q.fi, {I, J}});
        }
      }
    }
    for (int i = -2; i <= 2; i++){
      for (int j = -2; j <= 2; j++){
        int I = Q.se.fi + i, J = Q.se.se + j;
        if (0 <= I && I < H && 0 <= J && J < W){
          if (Dist[I][J] == -1 && S[I][J] == '.'){
            que.push({Q.fi + 1, {I, J}});
          }
        }
      }
    }
  }
  cout << Dist[Dh-1][Dw-1] << endl;

  return 0;
}


Measured memory_bytes: 9684
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1998244353
using namespace std;

int BIT[200002];
int n, k;
int a[200002];

void update(int idx, int val){
    while(idx <= n){
        BIT[idx] += val;
        idx += (idx) & (-idx);
    }
}

void updateRange(int l, int r){
    l = max(1, l);
    r = min(r, n);
    update(l, 1);
    update(r + 1, -1);
}

int getSum(int idx){
    int sum = 0;
    while(idx > 0){
        sum += BIT[idx];
        idx -= (idx) & (-idx);
    }
    return sum;
}

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

    cin >> n >> k;
    int mn = 1e9;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        updateRange(i + 1 - a[i], i + 1 + a[i]);
        mn = min(mn, a[i]);
    }
    while(mn < n && k > 0){
        mn = 1e9;
        for(int i = 0; i < n; i++){
            a[i] = getSum(i + 1);
            mn = min(a[i], mn);
        }
        memset(BIT, 0, sizeof BIT);
        for(int i = 0; i < n; i++){
            updateRange(i + 1 - a[i], i + 1 + a[i]);
        }
        k--;
    }
    for(int i = 0; i < n; i++){
        cout << a[i] << " ";
    }
}


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

int b[1002] = { 0 };

int main() {
	int n, m;
	int a[1002];
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= m; ++i) {
		int num;
		cin >> num;
		for (int j = 1; j <= n; ++j) {
			if (num >= a[j]) {
				++b[j];
				break;
			}
		}
	}

	int ans, max = 0;
	for (int i = 1; i <= n; ++i) {
		if (max < b[i]) {
			max = b[i];
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3100
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 2e5+5, OO = 0x3f3f3f3f;
//int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Directio
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class CManyFormulas {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s; in >> s;
        ll ans = 0ll;
        int n = s.size();
        REP(x, 1<<(n-1)) {
            ll acc = 0;
            REP(i, n) {
                acc *= 10;
                acc += s[i] - '0';
                if ((x&(1<<i)) == 0) {
                    ans += acc;
                    acc = 0;
                }
            }
            ans += acc;
        }
        out << ans << el;
	}
};


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


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	

	int n;
	int m;
	int a[100][100] = { 0 };
	int b[100] = { 0 };

	scanf("%d %d", &n, &m);

	int i = 0;
	int j = 0;
	for (; j < n; j++) {
		for (i = 0; i < m; i++) {
			scanf("%d", &a[j][i]);
		}
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}

	int c[100] = { 0 };

	for (j = 0; j < n; j++) {
		for (i = 0; i < m; i++) {
			c[j] += a[j][i] * b[i];
		}
	}

	for (j = 0; j < n; j++) {
		printf("%d\n", c[j]);
	}


	return 0;
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef long long ll;
const int N = 3e5+5;
ll n, a[N], L[N], R[N];
oset s;
int main()
{
	cin >> n;
	n *= 3;
	for(int i=0; i<n; i++) cin >> a[i];
	ll sum = 0;
	for(int i=0; i<n/3; i++) sum += a[i], s.insert(a[i]);
	L[n/3-1] = sum;
	int k = n/3;
	for(int i=n/3; i<n; i++)
	{
		int tmp = s.order_of_key(a[i]);
		s.insert(a[i]);
		if(s.size() - s.order_of_key(a[i]) <= k)
		{
			sum += a[i];
			sum -= *s.find_by_order(s.size()-k-1);
	 	}
 	 	L[i] = sum;
	}
	s.clear();
	sum = 0;
	for(int i=0; i<n/3; i++) sum += a[n-i-1], s.insert(-a[n-i-1]);
	R[n-k] = sum;
	for(int i=n/3; i<n; i++)
	{
		int tmp = s.order_of_key(-a[n-i-1]);
		s.insert(-a[n-i-1]);
		if(s.size() - s.order_of_key(-a[n-i-1]) <= k)
		{
			sum += a[n-i-1];
			sum += *s.find_by_order(s.size()-k-1);
	 	}
 	 	R[n-i-1] = sum;
 	 	//cout << R[n-i-1] << " ";
	}
	ll ans = -1e17;
	for(int i=k-1; i<n-k; i++) ans = max(ans, L[i]-R[i+1]);
	cout << ans << endl;
}

Measured memory_bytes: 20864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
#define inf INT64_MAX
int32_t main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int d, t, s;
    cin >> d >> t >> s;
    if(s*t >= d)
    {
        outline("Yes");
    }
    else
    {
        outline("No")
    }
    
    return 0;
}

Measured memory_bytes: 3648