akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
 
int dp[10001];
int N,W;
int main() {
    scanf("%d%d",&N,&W);
 
    for(int i = 0;i < N;i++) {
        int v,w;
        scanf("%d%d",&v,&w);
        for(int j = w;j <= W;j++) {
            dp[j] = max(dp[j],dp[j - w] + v);
        }
    }
    printf("%d\n",dp[W]);
    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

double kyori(pair<double,double> a, pair<double,double> b)
{
    double tmpx = a.first - b.first;
    double tmpy = a.second - b.second;
    double ans = sqrt(pow(tmpx,2.0) + pow(tmpy,2.0));
    return ans;
}

double eikaku(pair<double,double> a, pair<double,double> b, pair<double,double> c)
{
    double k1 = kyori(a,b);
    double k2 = kyori(b,c);
    double k3 = kyori(c,a);
    pair<double,double> d,e;
    d.first = b.first - a.first;
    d.second = b.second - a.second;
    e.first = c.first - a.first;
    e.second = c.second - a.second;
    double s = abs(d.first*e.second - d.second*e.first)/2.0;
    double ans = k1*k2*k3/4.0/s;
    return ans;
}

int main()
{
    ll i,j,k;
    ll n;
    cin >> n;
    vector<pair<ll,ll>> xy(n);
    for(i = 0;i < n;++i){
        cin >> xy.at(i).first >> xy.at(i).second;
    }
    if(n == 2){
        double ans = kyori(xy.at(0), xy.at(1));
        cout << fixed << setprecision(10) << ans/2.0 << endl;
        return 0;
    }
    double ans = 0.0;
    for(i = 0;i < n-2;++i){
        for(j = i+1;j < n-1;++j){
            for(k = j+1;k < n;++k){
                double k1 = kyori(xy.at(i), xy.at(j));
                double k2 = kyori(xy.at(j), xy.at(k));
                double k3 = kyori(xy.at(i), xy.at(k));
                double ksum = k1+k2+k3;
                double kmax = max({k1,k2,k3});
                double kmin = min({k1,k2,k3});
                double kmid = ksum-kmax-kmin;
                double tmp;
                if(kmax*kmax >= kmin*kmin + kmid*kmid) tmp = kmax/2.0;
                else tmp = eikaku(xy.at(i), xy.at(j), xy.at(k));
                ans = max(ans,tmp);
            }
        }
    }
    cout << fixed << setprecision(10) << ans << endl; 

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split(' ').map(&:to_i)

m = 0
ans = []

min = a.min
min_i = a.find_index(min)
max = a.max
max_i = a.find_index(max)

positive = max >= -min

if positive
  (1..(a.size-1)).each do |i|
    loop do
      break if a[i-1] <= a[i]
      a[i] += a[max_i]
      ans << [max_i, i]
      m += 1

      if max < a[i]
        max = a[i]
        max_i = i
      end
    end
  end
else
  (0..(a.size-2)).reverse_each do |i|
    loop do
      break if a[i+1] >= a[i]
      a[i] += a[min_i]
      ans << [min_i, i]
      m += 1

      if min > a[i]
        min = a[i]
        min_i = i
      end
    end
  end
end


puts m
ans.each do |a|
  puts "#{a[0]+1} #{a[1]+1}"
end



Measured memory_bytes: 1788
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void chmax(T &x, T y) { x = max(x, y); }
template <typename T> void chmin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  sort(a.rbegin(), a.rend());
  map<int, int> cnt;
  rep(i, n) cnt[a[i]]++;
  int ans = 0;
  rep(i, n) {
    if (cnt[a[i]] == 0) continue;
    cnt[a[i]]--;
    int m = 1;
    while (a[i] >= m) m <<= 1;
    int b = m - a[i];
    if (cnt[b] == 0) continue;
    cnt[b]--;
    ans += 1;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	set<int> st;
	for(int i = 1; i < k; ++i){
		st.insert(p[i]);
	}
	int ans = 1;
	rep(i,n-k){
		if(!(p[i] < *st.begin() && *st.rbegin() < p[i+k])) ++ans;
		st.erase(p[i+1]);
		st.insert(p[i+k]);
	}
	int cnt = 1, dup = 0;
	rep(i,n-1){
		if(p[i] < p[i+1]) ++cnt;
		else cnt = 1;
		if(cnt == k) ++dup;
	}
	if(dup > 0) ans -= dup - 1;
	cout << ans << endl;
	return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

lli dp[100002];

int main() {
    lli n;
    cin >> n;
    lli h[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }

    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int n;
  long long ans=0;
  scanf("%d",&n);
  for(;n>0;n--){
    if(n%3!=0 && n%5!=0){
      ans += n;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int H,W,K;
    cin>>H>>W>>K;
    int xs,ys,xg,yg;
    cin>>xs>>ys>>xg>>yg;
    --xs;--ys;--xg;--yg;
    vector<vector<int>> rake(H,vector<int>(W));
    rep(i,H)rep(j,W){
        char c;
        cin>>c;
        if(c=='@'){
            rake.at(i).at(j)=1;
        }
    }
    vector<vector<int>> ans(H,vector<int>(W,-1));
    ans.at(xs).at(ys)=0;
    queue<P> q;
    q.push({xs,ys});
    while(!q.empty()){
        P p=q.front();q.pop();
        int x=p.first,y=p.second;
        int now=ans.at(x).at(y);
        if(x==xg && y==yg){
            cout<<now<<endl;
            return 0;
        }
        for(int i=1;i<=K;i++){
            if(x+i>=H)break;
            if(rake.at(x+i).at(y))break;
            if(ans.at(x+i).at(y)>=0 && ans.at(x+i).at(y)<=now)break;
            if(ans.at(x+i).at(y)>=0 && ans.at(x+i).at(y)==now+1)continue;
            ans.at(x+i).at(y)=now+1;
            q.push({x+i,y});
        }
        for(int i=1;i<=K;i++){
            if(x-i<0)break;
            if(rake.at(x-i).at(y))break;
            if(ans.at(x-i).at(y)>=0 && ans.at(x-i).at(y)<=now)break;
            if(ans.at(x-i).at(y)>=0 && ans.at(x-i).at(y)==now+1)continue;
            ans.at(x-i).at(y)=now+1;
            q.push({x-i,y});
        }
        for(int i=1;i<=K;i++){
            if(y+i>=W)break;
            if(rake.at(x).at(y+i))break;
            if(ans.at(x).at(y+i)>=0 && ans.at(x).at(y+i)<=now)break;
            if(ans.at(x).at(y+i)>=0 && ans.at(x).at(y+i)==now+1)continue;
            ans.at(x).at(y+i)=now+1;
            q.push({x,y+i});
        }
        for(int i=1;i<=K;i++){
            if(y-i<0)break;
            if(rake.at(x).at(y-i))break;
            if(ans.at(x).at(y-i)>=0 && ans.at(x).at(y-i)<=now)break;
            if(ans.at(x).at(y-i)>=0 && ans.at(x).at(y-i)==now+1)continue;
            ans.at(x).at(y-i)=now+1;
            q.push({x,y-i});
        }
    }
    
    cout<<-1<<endl;
}

Measured memory_bytes: 14872
#include <iostream>
    #include <string>
    #include <algorithm>
    #include <cstdio>
    #include <vector>
    #include <queue>
    #include <set>
    #include <numeric>
    #include <cmath>
     
    using namespace std;
     
    typedef long long int ll;
     
    #define all(x) x.begin(),x.end()
     
    const ll mod = 1e9+7;
    const ll INF = 1e9;
    const ll MAXN = 1e9;
     
    int main()
    {
    	ll n;
    	cin >> n;
    	vector<ll> a(n);
    	for(int i = 0; i < n; i++){
    		cin >> a[i];
    	}
     
    	ll ans = 0;
    	for(int i = 0; i < n; i++){
    		if(a[i] > 0){
    			if(i>0 && a[i-1] == 1){
    				ans += 1;
    				a[i]--;
    			}
    			ans += a[i]/2;
    			a[i] %= 2;
    		}
    	}
     
    	cout << ans << endl;
     
    	return 0;
    }

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

int main () {
    
    long int a;
    long int b;
    long int k;
    long int m = 0;

    cin >> a;
    cin >> b;
    cin >> k;

    if (a >= k) {
        cout << a - k << " " << b;
    } else {
        cout << 0 << " " << max(a + b - k, m);
    };

    return 0;

}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size()<=k) {
        cout << s << endl;
        return 0;
    } else {
        rep(i,k) {
            cout << s[i];
        }
        cout << "..." << endl;
        return 0;
    }
}

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

namespace AtCoder.Abc
{
    class QuestionI
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long num_N = long.Parse(Console.ReadLine());

            int num_500Joy = 1000;
            int num_5Joy = 5;

            long num_500Coin = num_N / 500;
            long num_5Coin = (num_N - (num_500Coin * 500)) / 5;

            long result = num_500Coin * num_500Joy + num_5Coin * num_5Joy;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
N,M = map(int,input().split())
S = []
K = []
for i in range(M):
    s = list(map(int,input().split()))
    k = s.pop(0)
    S.append(s)
    K.append(k)
P = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    sw = [0]*N
    for j in range(N):
        if (i>>j)&1:
            sw[j] = 1
    flag = 1
    for m in range(M):
        po = S[m]
        sum = 0
        for k in range(K[m]):
            if sw[po[k]-1] == 1:
                sum = (sum + 1)%2
        if P[m] != sum:
            flag = 0
    if flag == 1:
        ans += 1
print(ans)

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

using namespace std;

int main(void){
    int P, Q, R;
    cin>>P>>Q>>R;
    if(P+Q <= Q+R && P+Q <= R+P)cout<<P+Q<<endl;
    else if(Q+R <= R+P && Q+R <= P+Q)cout<<Q+R<<endl;
    else cout<<R+P<<endl;
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local N, A, B = read.nnn()
local n, rem = N // (A+B), N % (A+B)
local b = n * A + math.min(A, rem)
print(b)

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
 
int main(){
    string a,b;
    cin>>a>>b;
    cout<<b<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
*A, = map(int,input().split())

B = [a for a in A if a>=0]
B.sort()
C = [a for a in A if a<0]
C.sort(reverse = True)

ans = 1
MOD = 10**9+7

if len(B)==0 and K%2==1:
    C.sort()
    for _ in [0]*K:
        ans *= C.pop()
        ans %= MOD
    print(ans)
    exit()

if K==N:
    for a in A:
        ans = ans * a % MOD
    print(ans)
    exit()

while K>=2:
    if len(B)>=2 and len(C)>=2:
        if B[-1]*B[-2] > C[-1]*C[-2]:
            ans *= B.pop()*B.pop()%MOD
            ans %= MOD
            K -= 2
        else:
            ans *= C.pop()*C.pop()%MOD
            ans %= MOD
            K -= 2
    elif len(C)>=2:
        ans *= C.pop()*C.pop()%MOD
        ans %= MOD
        K -= 2
    else:
        ans *= B.pop()
        ans %= MOD
        K -=1
if K==1:
    ans *= B.pop()
    ans %= MOD

ans %= MOD
print(ans)

Measured memory_bytes: 33364
#include <stdio.h>
#include <stdlib.h>


int main() {
  int N, L;
  int i;
  scanf ("%d %d", &N, &L);
  
  if      (L>0)     printf("%d", ((L+1)+(L+N-1))*(N-1)/2);
  else if (L+N-1<0) printf("%d", (L+(L+N-2))*(N-1)/2);
  else              printf("%d", (L+(L+N-1))*(N)/2);
  
  return 0;
}
 

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

#include<iostream>
#include<string>
#include<vector>
#include<algorithm> 
#include<functional> 
#include<cassert>
#include<numeric>
// std::accumulate(vec.begin(),vec.end(),0) sum of element
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<queue>


using namespace std;

typedef long long ll;
typedef std::pair<int, int> pii;
typedef vector<int> vi;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define show(x) cout << #x << " = " << x << endl

#define fi first
#define se second
#define pb push_back
#define mk make_pair


template <class X>
void unique_vector(std::vector<X> &t);
template <class X>
void print_vector(const std::vector<X> &t);

int main(){
  int n;
  cin >> n;
  vi u(n+1);

  rep1(i,n)
    scanf("%d", &u[i]);

  int c = 0;
  rep1(i, n){
    if(u[i] == -1)
      continue;
    if(u[u[i]] == i){
      u[u[i]] = -1;
      u[i] = -1;
      c++;
    }

  }
  
  cout << c << endl;
    
}


template <class X>
void unique_vector(std::vector<X> &t)
{
  std::sort(t.begin(), t.end());
  t.erase( std::unique(t.begin(), t.end()), t.end() );
}

template <class X>
void print_vector(const std::vector<X> &t){
  for(auto itr=t.begin(); itr != t.end(); itr++){
    std::cout << *itr;
    if(itr != t.end()-1) std::cout << ' ';
  }
  std::cout << std::endl;
}


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

int main() {
	int h, w;
	while (true) {
		cin >> h >> w;
		if ((h | w) != 0) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (i > 0 && i < h - 1 && j > 0 && j < w - 1) {
						cout << ".";
					} else {
						cout << "#";
					}
				}
				cout << endl;
			}
			cout << endl;
		} else {
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
double ruijo(double x, int n) {
    double res = 1;
    rep(i, 0, n) { res *= x; }
    return res;
}
int intruijo(int x, int n) {
    int res = 1;
    rep(i, 0, n) { res *= x; }
    return res;
}
int main() {
    int N, M;
    cin >> N >> M;
    int LR[100010][2];
    rep(i, 0, M) { cin >> LR[i][0] >> LR[i][1]; }
    int le = 1;
    int ri = N;
    rep(i, 0, M) {
        if(LR[i][0] > le) {
            le = LR[i][0];
        }
        if(LR[i][1] < ri) {
            ri = LR[i][1];
        }
    }
    if(ri < le) {
        cout << 0 << endl;
    } else {
        cout << ri - le + 1 << endl;
    }
}

Measured memory_bytes: 1024
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}

		int left = 0;
		int right = W;
		int bottom = 0;
		int top = H;

		for (int i = 0; i < N; i++) {
			switch (a[i]) {
			case 1:
				left = Math.max(left, x[i]);
				break;
			case 2:
				right = Math.min(right, x[i]);
				break;
			case 3:
				bottom = Math.max(bottom, y[i]);
				break;
			case 4:
				top = Math.min(top, y[i]);
				break;
			}
		}

		System.err.println(left + "," + right + "," + top + "," + bottom);
		if (right - left < 0 || top - bottom < 0) {
			System.out.println(0);
		} else {
			System.out.println((right - left) * (top - bottom));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 8148
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int maxv = -2000000000; // ???????°??????????????????????????¨????
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {     // ????????§??????R[i]?????????????????°??????????????????
    maxv = max(maxv, R[i] - minv);    // ?????§????????´??°
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 1940
import java.util.*;
 
public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      System.out.println(cnt);
    }
}


Measured memory_bytes: 52128
n = gets.to_i
a = gets.split.map(&:to_i)


for i in 0..(n-1)

j = i-1

while j >= 0

if a[j] < a[j+1] then
break
else
a[j], a[j+1] = a[j+1], a[j]
j -= 1
end

end

puts a.join(" ")

end


Measured memory_bytes: 6884
#include<bits/stdc++.h>
using namespace std;
int Count_Path(vector<bool> data,int now,bool**field,const int n){
  int count=0;
  bool check=true;
  for(int i=0;i<n;i++){
    if(!data[i]){
      check=false;
      if(field[now][i]){
        data[i]=true;
        count+=Count_Path(data,i,field,n);
        data[i]=false;
      }
    }
  }
  if(check)return 1;
  return count;  
}
int main(void){
  int n=0;
  int m=0;
  cin>>n>>m;
  bool**field=new bool*[n];
  vector<bool>data(n);
  for(int i=0;i<n;i++){
    field[i]=new bool[n];
    data[i]=false;
    for(int j=0;j<n;j++){
      field[i][j]=false;
    }
  }
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    field[a-1][b-1]=true;
    field[b-1][a-1]=true;
  }
  data[0]=true;
  cout<<Count_Path(data,0,field,n)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <math.h>

int main(void){
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);

    if(A>=13)printf("%d",B);
    if(A>=6 && A<=12)printf("%d",B/2);
    if(A<=5)printf("0");

    return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var D = (double)inputArray[0];
			var T = (double)inputArray[1];
			var S = (double)inputArray[2];


			//答えの出力
			var ans = T >= D/S ? "Yes":"No";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28236
n,q=map(int,input().split())
s=input();a=[0]*2
for i in range(2,n+1):
 a+=[a[i-1]+s[i-2:i].count("AC")]
for _ in range(q):
 l,r=map(int,input().split())
 print(a[r]-a[l])

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  long long A = 0;

  vector<long long> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    A += vec.at(i);
  }

  long long B = 0, ans = LLONG_MAX;

  for (int i = 0; i < N; i++) {
    B += vec.at(i);
    ans = min(ans, abs(B - (A - B)));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
a = []
n -= 1
for i in range(n):
    N, S, F = map(int, input().split())
    a.append([N, S, F])

for i in range(n + 1):
    cnt = 0
    for j in range(i, n):
        # print(i, j,n)
        if j == i:
            cnt += a[j][1] + a[j][0]
        else:
            if cnt >= a[j][1]:
                amari = cnt % a[j][2]
                cnt += a[j][0] + (a[j][2] - amari if amari != 0 else 0)
            else:
                cnt = a[j][1] + a[j][0]
    print(cnt)


Measured memory_bytes: 42348
#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    for(int i=0;i<100;i++){
        c=c-b;
        if(c<=0){
            printf("Yes\n");
            return 0;
        }
        a=a-d;
        if(a<=0){
            printf("No\n");
            return 0;
        }
    }
    return 0;
}

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

int main()
{
    long long a,b,c,x,y,ans;
    cin>>a>>b>>c>>x>>y;
    ans=max(x,y)*2*c;
    ans=min(ans,min(x,y)*2*c+((x>y)?(x-y)*a:(y-x)*b));
    ans=min(ans,a*x+b*y);
    cout<<ans;
    return 0;
}

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

int main()
{
  int number;
  number = 0;
  char input;
  char alphabet[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

  cin >> input;

  for (int i = 0; i < 26; i++)
  {
    if(input == alphabet[i])
    {
      number = i;
    }
  }

  cout << alphabet[number + 1] << endl;

}


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

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

    int k;
    cin >> k;
    vector<ll> a(k + 1);
    rep(i, k) cin >> a[i + 1];
    a[0] = 1LL;

    ll l = 2LL, r = 2LL;
    if (a[k] != 2LL)
    {
        cout << -1 << endl;
        return 0;
    }
    for (int i = k; i >= 0; i--)
    {
        ll r2 = r / a[i] * a[i];
        ll l2 = (l + a[i] - 1) / a[i] * a[i];
        if (r2 < l2)
        {
            cout << -1 << endl;
            return 0;
        }
        l = l2;
        r = r2 + a[i] - 1;
    }
    cout << l << ' ' << r << endl;

    return 0;
}


Measured memory_bytes: 1024
x,n=map(int,input().split())
p=set(map(int,input().split()))

if n==0:
  print(x)
  exit(0)
if x not in p:
  print(x)
  exit(0)

ans=1
while True:
  if x-ans not in p:
    print(x-ans)
    exit(0)
  elif x+ans not in p:
    print(x+ans)
    exit(0)
  ans+=1


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

typedef long long int ll;

using namespace std;

int main()
{
  ll N,count=1,ans=0;

  cin >> N;
  vector<ll> vec(N);

  
  for (ll i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  /*for (ll i = 0; i < N; i++) {
    cout << vec.at(i);
  }*/

  for (ll i = 0; i < N; i++) {
    if(count==vec.at(i)){
      count++;
    }
  }

  //cout << count << endl;

  if(count>=2){
    cout << N - count + 1 << endl;
  }
  else{
    cout << -1 << endl;
  }
}

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

int main() {
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for (int i = 0, len = n - 2; i < len; i++) {
        if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3564
import scala.io.StdIn.{readInt,readLine}

object Main {
  def main(args:Array[String]) = {
    val n = readInt
    val m = readInt
    val target = readLine.split(" ").map(_.toInt)
    val score = new Array[Int](n)
    for(i<-0 until m) {
      val guess = readLine.split(" ").map(_.toInt)
      val t = target(i)
      for(j<-0 until guess.length) {
        if(guess(j)==t) score(j) += 1
        else score(t-1) += 1
      }
    }
    println(score.mkString("\n"))
  }
}

Measured memory_bytes: 45692
#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctype.h>

const int INF =100000000;

using namespace std;

int main(){

  while(1){

    int n;
    int cc = 0;
    cin >> n;

    if(!n){
      break;
    }else{
      int d[1002][4] = {0};
      int p,q,r,c;
      for(int i = 0;i < n;i++){
	cin >> d[i][0] >> d[i][1] >> d[i][2] >> d[i][3];
      }
      cin >> p >> q >> r >> c;

      for(int i = 0;i < n;i++){
	if(d[i][1] <= p && d[i][2] <= q && d[i][3] <= r && d[i][1]*4 + d[i][2]*9 + d[i][3]*4 <= c){
	  cout << d[i][0]<<endl;
	  cc = 1;
	}
      }
    }
    if(cc == 0) cout << "NA" << endl;
  }
}


Measured memory_bytes: 1184
{-# OPTIONS_GHC -Wall #-}

import Control.Monad
import Data.Array

readInt :: String -> Int
readInt = read

calcDp :: Int -> Int -> Array Int Int -> Array Int Int -> Array (Int,Int) Int
calcDp n wmax vs ws = dp
    where
        -- i種類目までで容量jで実現できる最大価値
        dp = listArray ((0,0),(n,wmax)) [f i j | i<-[0..n], j<-[0..wmax]]
        f _ 0 = 0
        f 0 _ = 0
        f i j
            | j >= w    = max (v+dp!(i,j-w)) (dp!(i-1,j))
            | otherwise = dp!(i-1,j)
            where
                v = vs!(i-1)
                w = ws!(i-1)

main :: IO ()
main = do
    [n,wmax] <- fmap (map readInt . words) getLine
    vws      <- replicateM n $ do
        [v,w] <- fmap (map readInt . words) getLine
        return (v,w)
    let vs = listArray (0,n-1) $ map fst vws
    let ws = listArray (0,n-1) $ map snd vws

    let dp  = calcDp n wmax vs ws
    let ans = dp!(n,wmax)

    --print $ dp
    print $ ans



Measured memory_bytes: 138032
#include <stdio.h>
int main(void){
    char a[9][9];
    int i,j;
    
    while(scanf("%s",a[0]) != EOF){
        for(i=1;i<8;i++){
            scanf("%s",a[i]);
        }
        
        //for(i=0;i<8;i++){
        //    for(j=0;j<8;j++){
        //        printf("%c",a[i][j]);
        //        if(j==7)puts("");
        //    }
        //}
        
        for(i=0;i<8;i++){
            for(j=0;j<8;j++){
                if(a[i][j]=='1')break;
            }
            if(a[i][j]=='1')break;
        }
        
        //printf("%d %d\n",i,j);
        
        if(i<7 && j<7 && a[i+1][j]=='1' && a[i][j+1]=='1' &&a[i+1][j+1]=='1')puts("A");
        if(i<5 && a[i+1][j]=='1' && a[i+2][j]=='1' && a[i+3][j]=='1')puts("B");
        if(j<5 && a[i][j+1]=='1' && a[i][j+2]=='1' && a[i][j+3]=='1')puts("C");
        if(i<6 && j>0 && a[i+1][j]=='1' && a[i+1][j-1]=='1' && a[i+2][j-1]=='1')puts("D");
        if(i<7 && j<6 && a[i][j+1]=='1' && a[i+1][j+1]=='1' && a[i+1][j+2]=='1')puts("E");
        if(i<6 && j<7 && a[i+1][j]=='1' && a[i+1][j+1]=='1' && a[i+2][j+1]=='1')puts("F");
        if(i<7 && j<7 && j>0 && a[i][j+1]=='1' && a[i+1][j]=='1' && a[i+1][j-1]=='1')puts("G");
    }
    
    return 0;
    
}

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

int main() {
    string s;
    cin >> s;
    stack<char> st;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (!st.empty() && s[i] != st.top()) {
            ans += 2;
            st.pop();
        } else {
            st.push(s[i]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
string A, B;
int main() {
	
	cin >> A >> B;
	if (A.length() > B.length()){
		cout << "GREATER" << endl;
		
	}
	 else if (A.length() < B.length()) {
		cout << "LESS" << endl;
		
	}

	 else {
		if (A > B) {
			cout << "GREATER" << endl;
			
		}
		else if (A < B) {
			cout << "LESS" << endl;
			
		}
		 else{
			cout << "EQUAL" << endl;
			return 0;
		}
	}

		
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define f0(i,n)for(ll i=0;i<n;i++)
#define f0r(i,n)for(ll i=n-1;i>=0;i--)
#define fc(i,c,n,s)for(ll i=c;i<=n;i+=s)
#define fcr(i,c,n,s)for(ll i=n;i>=c;i-=s)
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif
	ll n,m;
	cin >> n >> m;
	ll ans = (n + m - 1) / m;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define Mod 1000000007

using namespace std;

void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int main(){
	fastio();
	ll n,k,ans=0;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x>=k)++ans;
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
list_str = []
list_p = []
for _ in range(n):
  s = input()
  if s in list_str:
    list_p[list_str.index(s)] += 1
  else:
    list_str.append(s)
    list_p.append(1)
m = int(input())
for _ in range(m):
  t = input()
  if t in list_str:
    list_p[list_str.index(t)] -= 1
  else:
    list_str.append(s)
    list_p.append(-1)
if max(list_p) >= 0:
  print(max(list_p))
else:
  print(0)

Measured memory_bytes: 3064
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut N: u32 = sc.read();
    let mut ans = 0;
    for i in 1..(N/2+1) {
        if i != N - i {
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2104
/** author: __nishad__ **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    string s;
    cin>>s;

    cout<<s[0]<<s.size()-2<<s[s.size()-1];


}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Ad = {}
ans = [0]*N
i=0
for i in range(len(A)):
  Ad[i] = A[i]

i=0
for k, v in sorted(Ad.items(), key=lambda x: x[1]):
  ans[i] = k+1
  i+=1

print(*ans)

Measured memory_bytes: 29556
#include <string.h>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string, long long> a;
int main() {
    int N, j;
    while (cin >> N) {
        char ch[11];
        string str;

        int i;
        for (i = 1; i <= N; i++) {
            cin >> ch;
            sort(ch, ch + strlen(ch));
            str = ch;
            a[str]++;
        }
        long long sum = 0;
        for (map<string, long long>::iterator it = a.begin(); it != a.end();
             it++) {
            sum += (it->second - 1) * it->second / 2;
        }

        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
int main() {
  int n,ans=0;
  int c[50],v[50];
  scanf("%d", &n);
  for(int i=0;i<n;i++){
      scanf("%d",&v[i]);
  }
  for(int i=0;i<n;i++){
      scanf("%d",&c[i]);
  }
  for(int i=0;i<n;i++){
      if(v[i]>c[i]){
          ans+=v[i]-c[i];
      }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int i;
    int k=0;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            k++;
        }
    }
    cout<<k<<endl;
}


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

int main()
{
  ll x,a,b; cin >> x >> a >> b;
  if (a-b >= 0) cout << "delicious" << endl;
  else if (b-a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "Yes";
    if (a+b<c) ans = "No";
    
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vll A(N);
  REP(i,N){
    IN(A[i]);
  }

  sort(ALL(A));

  vll H(1E6+10, 0);

  ll ans = 0;
  REP(i,N){
    bool flag = true;

    ll A_copy = A[i];
    ll sqrt_A = (ll)sqrt(A[i]+1)+10;

    if(H[1]>0) flag = false;
    FOR(j,2,sqrt_A){
      if(A[i]%j==0){
        if(H[j]>0) flag = false;
        if(H[A[i]/j]>0) flag = false;
      }
    }
    if(H[A_copy]>0) flag = false;

    if(i<N-1){
      if(A[i]%A[i+1]==0) flag = false;
    }

    if(flag) ans++;

    H[A[i]]++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 12720
#include <iostream>
#include <set>
#define ll long long

using namespace std;

ll n2, n;
multiset <int> s1, s2;

int main()
{
    cin >> n;
    n2 = (1 << n);

    for(int i = 1; i <= n2; ++i)
    {
        int x;
        cin >> x;
        s1.insert(x);
    }

    auto it1 = s1.end();
    --it1;
    s2.insert(*it1);
    s1.erase(it1);

    for(int i = 1; i <= n; ++i)
    {
        for(auto it2 = s2.begin(); it2 != s2.end(); ++it2)
        {
            auto it3 = s1.lower_bound(*it2);

            if(it3 == s1.begin())
            {
                cout << "No"; ///pe
                return 0;
            }

            --it3;

            if(*it3 > *it2)
            {
                cout << "No"; ///pe
                return 0;
            }

            s2.insert(*it3);
            s1.erase(it3);
        }
    }

    cout << "Yes"; ///p
    return 0;
}


Measured memory_bytes: 12544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);
    	int K = sc.nextInt();
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	boolean result = false;

    	for(int i=A;i<=B;i++) {
    		if(i%K==0) {
    			result = true;
    			break;
    		}
    	}
    	if(result) {
    		System.out.println("OK");
    	} else {
    		System.out.println("NG");
    	}

    }
}

Measured memory_bytes: 27084
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC125C
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static public void Main(string[] args)
        {
            var N = Console_.NextInt();
            var Aary = new int[N];
            for (int i = 0; i < N; ++i)
            {
                Aary[i] = Console_.NextInt();
            }
            var Lary = new int[N];
            var Rary = new int[N];
            for (int i = 1; i < Aary.Length; ++i)
            {
                if (i == 1)
                {
                    Lary[i - 1] = Aary[i - 1];
                }
                else
                {
                    Lary[i - 1] = gcd(Aary[i - 1], Lary[i - 2]);
                }
            }
            for (int i = Aary.Length - 2; i > -1; --i)
            {
                if (i == Aary.Length - 2)
                {
                    Rary[i + 1] = Aary[i + 1];
                }
                else
                {
                    Rary[i + 1] = gcd(Aary[i + 1], Rary[i + 2]);
                }
            }
            int max = 0;
            for (int i = 0; i < Aary.Length; ++i)
            {
                int v = 0;
                if(i == 0) {
                    v = Rary[i + 1];
                }else if(i == Aary.Length - 1) {
                    v = Lary[i - 1];
                }else {
                    v = gcd(Rary[i + 1], Lary[i - 1]);
                }
                if(max < v) {
                    max = v;
                }
            }
 
            Console.WriteLine(max);
        }
 
        static int gcd(int a, int b)
        {
            if (b == 0) return a;
            return gcd(b, a % b);
        }
    }
}


Measured memory_bytes: 28892
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <utility>
#include <algorithm>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long H, long long N, std::vector<long long> A, std::vector<long long> B) {
    vector<i64> dp(10010, numeric_limits<i64>::max());
    vector<i64> way(10010, numeric_limits<i64>::max());
    dp[0] = 0;
    rep1(i, N) {
        rep2(j, 1, 10010) {
            if (j * A[i] >= H) {
                way[H] = min(way[H], j * B[i]);
                break;
            }
            else {
                way[A[i] * j] = min(way[A[i] * j], j * B[i]);
            }
        }
    }
    //if(H == 9) rep(i, H + 1) cout << way[i] << endl;
    rep1(i, H) {
        if (dp[i] == numeric_limits<i64>::max()) continue;
        rep2(j, 1, H + 1) {
            if (way[j] == numeric_limits<i64>::max()) continue;
            if (i + j >= H) dp[H] = min(dp[H], dp[i] + way[j]);
            else dp[i + j] = min(dp[i] + way[j], dp[i + j]);
        }
    }
    //if(H == 9) rep(i, H + 1) cout << dp[i] << endl;

    cout << dp[H] << endl;
}

int main() {
    long long H;
    scanf("%lld", &H);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
    }
    solve(H, N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 384