akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
	long long a,b;
	
	while(cin>>a>>b){
		int r = a%b;
		long long lcm = a*b;
		while(r != 0){
			a = b;
			b = (long)r;
			r = a%b;
					
		}
		lcm /= b;
		cout<<b<<" "<<lcm<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;



map<string,int>h;
string s[105];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        h[s[i]]++;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>s[n];
        h[s[n]]--;
    } 
    int max=0;
    for(int i=0;i<n;i++)
    if(h[s[i]]>max)
    max=h[s[i]];  
    cout<<max;
   // system("pause");
    return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>

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; }

char ToUpper(char cX) { return toupper(cX); }
char Tolower(char cX) { return tolower(cX); }

const long long INF = 1LL << 60;
const long long MOD = 1000000007;

using namespace std;
typedef unsigned long long ull;
typedef  long long ll;

vector<vector<ll>> dp;
vector<ll>a;
vector<ll>l;
ll lis() {
	l.push_back(a[0]);
	for (ll i = 0; i < a.size(); i++) {
		if (l[l.size() - 1] < a[i]) {
			l.push_back(a[i]);
		}
		else {
			*lower_bound(l.begin(), l.end(), a[i]) = a[i];
		}
	}
	return l.size();
}

int main()
{
	ll n;
	cin >> n;
	a = vector<ll>(n, 0);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	cout << lis() << endl;
	return 0;
}



Measured memory_bytes: 4680
n,m = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
b = [int(input()) for _ in range(m)]

for i in range(n):
    ci = 0
    for j in range(m):
        ci += A[i][j]*b[j]
    print(ci)



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

using namespace std;

using ll = long long;

struct Edge {
    int u, v, w;
};

const int N = 1e5 + 5;

ll p[N], sum[N], mx[N], kek[N];
int bad;

int getRoot(int v) {
    return v == p[v] ? v : p[v] = getRoot(p[v]);
}

void unite(int v, int u, ll weight) {
    v = getRoot(v), u = getRoot(u);
    if (v == u) {
        mx[v] = max(mx[v], weight);
        if (weight > sum[v]) {
            kek[v]++;
            bad++;
        }
        return;
    }
    p[u] = v;
    sum[v] += sum[u];
    mx[v] = max({ mx[v], mx[u], weight });
    bad -= kek[v] + kek[u];
    if (mx[v] > sum[v]) {
        kek[v] += kek[u] + 1;
    } else {
        kek[v] = 0;
    }
    bad += kek[v];
}

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

    int n, m;
    cin >> n >> m;
    iota(p, p + n, 0);
    for (int i = 0; i < n; i++) {
        cin >> sum[i];
    }
    vector<Edge> edges(m);
    for (int i = 0; i < m; i++) {
        cin >> edges[i].u >> edges[i].v >> edges[i].w;
        edges[i].u--;
        edges[i].v--;
    }
    sort(edges.begin(), edges.end(), [](auto& a, auto& b) {
        return a.w < b.w;
    });
    
    for (auto edge : edges) {
        unite(edge.u, edge.v, edge.w);
    }

    cout << bad << endl;
    return 0;
}

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

int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  cout << ((s < t) ? "Yes" : "No");
  return 0;
}


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

#define MAX 32768

int dp[5][MAX + 1];

int main(){
	dp[0][0] = 1;
	
	for(int i = 1; i * i <= MAX; ++i){
		int i2 = i * i;
		
		for(int j = i2; j <= MAX; ++j){
			for(int k = 1; k <= 4; ++k){
				dp[k][j] += dp[k - 1][j - i2];
			}
		}
	}
	
	for(int i = 1; i <= MAX; ++i){
		for(int k = 1; k <= 4; ++k){
			dp[0][i] += dp[k][i];
		}
	}
	
	int n;
	while( scanf("%d", &n), n != 0 ){
		printf("%d\n", dp[0][n]);
	}
}

Measured memory_bytes: 1668
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   int n;
   double a;
   cin >> n;
   
   vi s(n);
   
   rep(i,n){
      cin >> a;
      if(a<165) s[0]++;
      else if(a<170) s[1]++;
      else if(a<175) s[2]++;
      else if(a<180) s[3]++;
      else if(a<185) s[4]++;
      else s[5]++;
   }
   rep(i,6){
      cout << i+1 << ":";
      rep(j,s[i]) cout << "*"; cout << endl;
   }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s, t;
  in2(s, t);
  bool f = true;
  if(s.size() != t.size() - 1)
    f = false;
  rep(i, s.size()){
    if(s[i] != t[i])
      f = false;
  }
  if(f)
    out("Yes");
  else
    out("No");
  memi;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    char c;
    cin>>c;

    cout<< (char)(c+1);

    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

int main(){
	map<int,int> mp;

	int n;
	cin >> n;
	for(int i = 2;i <= n;i++){
		int k = i;
		for(int j = 2;j * j <= k;j++){
			while(k % j == 0){
				k /= j;
				mp[j]++;
			}
		}
		if(k != 1)mp[k]++;
	}

	vector<int> v;
	for(auto p:mp)v.push_back(p.second);


	ll ans = 0;

	int m = v.size();
	for(int i = 0;i < m-2;i++){
		for(int j = i + 1;j < m - 1;j++){
			for(int k = j + 1;k < m;k++){
				if(v[i] >= 2 && v[j] >= 4 && v[k] >= 4)ans++;
				if(v[i] >= 4 && v[j] >= 2 && v[k] >= 4)ans++;
				if(v[i] >= 4 && v[j] >= 4 && v[k] >= 2)ans++;
			}
		}
	}

	for(int i = 0;i < m;i++){
		if(v[i] >= 74)ans++;
	}

	for(int i = 0;i < m - 1;i++){
		for(int j = i + 1;j < m;j++){
			if(v[i] >= 2 && v[j] >= 24)ans++;
			if(v[i] >= 24 && v[j] >= 2)ans++;
			if(v[i] >= 4 && v[j] >= 14)ans++;
			if(v[i] >= 14 && v[j] >= 4)ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline

N,A,B,C,D = map(int, input().split())
S = input().strip()

if "##" in S[A:C] or "##" in S[B:D]:
    print("No")
    exit()

if D < C:
#    print(S[A:D])
    if "..." not in S[B-2:D+1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3572
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
ll n;
vector<ll> v(n);

int main(){
	cin>>n;
	v = vector<ll>(n);
	rep(i, n) cin>>v[i];
	ll ub = 0;
	rep(i, n) ub += v[i];
	ll lb = max(0LL, ub - (n-1)*(n));
	rep(i, n) v[i] += lb;
	ll res = 0;
	rep(i, n){
		res += v[i]/(n+1);
		v[i] %= n+1;
	}
	rep(i, n) v[i] += res-lb;
	bool f;
	do{
		f = false;
		rep(i, n){
			if(v[i]>=n){
				res++;
				v[i] -= n+1;
				rep(j, n) v[j]++;
				f = true;
			}
		}
	} while(f);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
const int maxn=57;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int x[maxn];
int y[maxn];
int z[maxn][maxn];
int e[maxn];
int f[maxn];
int g[maxn];
int n, m;
typedef long long ll;
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
    {
		scanf("%d%d", &a[i], &b[i]);
		c[i] = a[i];
		d[i] = b[i];
	}
	sort(c, c + n);
	sort(d, d + n);

memset(z,0,sizeof z);
	for(int i=0;i<n;i++)
    {
        x[i]=lower_bound(c,c+n,a[i])-c+1;
        y[i]=lower_bound(d,d+n,b[i])-d+1;
        z[x[i]][y[i]]++;
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            z[i][j]=z[i][j]+z[i-1][j]+z[i][j-1]-z[i-1][j-1];
        }
    }

    ll ans=3999999996000000009;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=i;k<=n;k++)
            {
                for(int s=j;s<=n;s++)
                {
                   if (z[k][s] - z[i - 1][s] -z[k][j - 1] + z[i - 1][j - 1] >= m)
                   {
						ans = min(ans, (ll) (c[k - 1] - c[i - 1]) *(d[s - 1] - d[j - 1]));
                   }
            }
        }
      }
    }
printf("%lld\n",ans);
return 0;

}

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

int N;

int main() {
    cin >> N;
    vector<long long> S(N + 1);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        S[i + 1] = S[i] + a;
    }
    
    int left = 1, right = 3;
    long long ans = 1e15;
    for (int mid = 2; mid < N - 1; mid++) {
        long long half = S[mid];
        
        while (S[left] < half / 2) {
            left++;
        }
        if (S[left] > half - S[left - 1]) {
            left--;
        }
        long long lmin = min(S[left], half - S[left]), lmax = max(S[left], half - S[left]);
        
        half = S[N] - S[mid];
        while (S[right] - S[mid] < half / 2) {
            right++;
        }
      
        if (S[right] - S[mid] > S[N] - S[right - 1]) {
            right--;
        }
        long long rmin = min(S[right] - S[mid], S[N] - S[right]), rmax = max(S[right] - S[mid], S[N] - S[right]);
        
        ans = min(ans, max(rmax, lmax) - min(rmin, lmin));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


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


def main():
    N, K = map(int, input().split())
    A = [int(s) for s in input().split()]

    pos = 1
    order = [-1] * (N+1)
    order[1] = 0
    s = [1]
    for i in range(1, N + 1):
        npos = A[pos-1]
        if i == K:
            print(npos)
            return
        if order[npos] != -1:
            l = order[npos]
            c = i - order[npos]
            break

        order[npos] = i
        s.append(npos)
        pos = npos

    L = l + (K - l) % c
    pos = s[L]

    print(pos)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32360
#include <stdio.h>
 
int main(void)
{
  int	n;
  int	numbers[110];
  int	bool = 1;
  
  scanf("%d", &n);
  int i = 0;
  while (i < n)
  {
    scanf("%d", &numbers[i]);
    i++;
  }
  i = 0;
  while (i < n)
  {
    if (numbers[i] % 2 == 0)
    {
      if (numbers[i] % 3 != 0 && numbers[i] % 5 != 0)
      {
		bool = 0;
      	break ;
      }
    }
    i++;
  }
  if (bool)
    printf("%s", "APPROVED");
  else
    printf("%s", "DENIED");
  return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;

int main()
{
    int N;
    string S;
    int result = 0;

    cin >> N;
    cin >> S;
    char previous = '0';
    for (int i = 0; i < (int)S.size(); i++)
    {
        char ch = S[i];
        if (ch != previous)
            result++;
        previous = ch;
    }
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

set<string> s;
bool ok;
ll ans;
int main() {
	ll n;
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		ans += a - i - 1;
	}
	cout << ans << endl;
}




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

int main() {
	long long A,B,C,K;
	cin >> A >> B >> C >> K;

	if(K<=A){
		cout << K << "\n";
	}else if(K<=A+B){
		cout << A << "\n";
	}else{
		cout << A - (K-A-B) << "\n";
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	int N; cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	ll m = 1000;
	ll past = 100000;

	int c = 0;
	while (c + 1 < A.size() && A[c] >= A[c + 1]) { c++; }

	ll start, end;
	while (c < A.size()) {
		if (c == A.size() - 1) { break; }
		start = A[c];
		while (c + 1 < A.size() && A[c] <= A[c + 1]) { c++; }
		end = A[c];
		ll k = m / start; m %= start;
		m += end * k;
		while (c + 1 < A.size() && A[c] >= A[c + 1]) { c++; }
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
int a,b,c,n,r;main(){while(std::cin>>a>>b>>c,a|b|c){a*=a;b*=b;c*=c;std::cin>>n;while(n--)std::cin>>r,r*=4*r,puts(a+b<r|b+c<r|c+a<r?"OK":"NA");}}

Measured memory_bytes: 0
#include <stdio.h>
int main(void)
{
  int n, i;
  int a[10000];
  int ans = 0;
  scanf("%d", &n);

  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
  }
  
  for(i = 0;i < n;i++){
    if(a[i] == a[i+1]){
      a[i+1] = a[i] + a[i+2];
      ans++;
    }
  }
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
_, a, b, c, d = gets.split.map(&:to_i)
s = gets.chomp
if c < d
  if /##/ === s[a - 1..d - 1]
    puts 'No'
  else
    puts 'Yes'
  end
else
  if /##/ === s[a - 1..d - 1]
    puts 'No'
  elsif /[.]{3}/ === s[b - 2..d]
    puts 'Yes'
  else
    puts 'No'
  end
end

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

typedef long long ll;

#define MAX(X,Y) (((X)>(Y))?(X):(Y))

int main () {
	int N, M;
	ll A[200001], B[200001];
	ll K, tmp;
	cin >> N >> M >> K;
	A[0] = 0;
	for (int i=0; i<N; i++) {
		cin >> tmp;
		A[i+1] = A[i] + tmp;
	}
	B[0] = 0;
	for (int j=0; j<M; j++) {
		cin >> tmp;
		B[j+1] = B[j] + tmp;
	}

	int ans = 0, j = M;
	for (int i=0; i<=N; i++) {
		if (A[i] > K)
			break;
		while (A[i]+B[j]>K)
			j --;
		ans = MAX (ans, i+j);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6672
import math

A, B = [int(i) for i in input().split()]
exclusiveA = 0
exclusiveB = 0
B += 1
for i in range(len(bin(B)) - 2):
    factorialNum = int(math.pow(2, i))
    numA = A // (factorialNum * 2) * factorialNum
    numA += max(A % (factorialNum * 2) - factorialNum, 0)
    numB = B // (factorialNum * 2) * factorialNum
    numB += max(B % (factorialNum * 2) - factorialNum, 0)
    if numA % 2 == 1:
        exclusiveA += factorialNum
    if numB % 2 == 1:
        exclusiveB += factorialNum

print(exclusiveB ^ exclusiveA)


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if ((A * 100 + B * 10 + C) % 4 == 0)
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int tmp, counter = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				tmp = 500 * i + 100 * j + 50 * k;
				if (tmp == X) counter++;
			}
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 384
n = gets.to_i
l_array = gets.split.map(&:to_i)
ans = 0

l_array.size.times do |i|
    a = l_array[i]
    (i + 1).step(l_array.size - 1) do |j|
        b = l_array[j]
        next if a == b
        (j + 1).step(l_array.size - 1) do |k|
            c = l_array[k]
            next if a == c
            next if b == c
            temp_array = [a, b, c]
            temp_array.sort!
            next if (temp_array[0] + temp_array[1]) <= temp_array[2]
            ans = ans + 1
        end
    end
end

puts ans


Measured memory_bytes: 14368
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define all(x) x.begin(), x.end()
#define rep(n) for (int i=0; i<n; ++i)

#define WILD 8

using namespace std;

int color(int rate) {
  rep(8) {
    if (rate < 400*(i+1)) return i;
  }
  return WILD;
}

int main(void){
  int N, max, min;
  cin >> N;
  vector<int> is_used(9);
  rep(N) {
    int rate;
    cin >> rate;
    ++is_used[color(rate)];
  }
  int nused = 0;
  rep(8) {
    if (is_used[i]) ++nused;
  }
  max = nused + is_used[WILD];
  min = std::max(1, nused);
  cout << min << " " << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  int alfa[26]={};
  int flag=1;
  for(int i=0;i<str.size();i++)
    alfa[str[i]-'a']++;
  for(int i=0;i<26;i++){
    if(alfa[i]==0){
      char a='a'+i;
      cout<<a<<endl;
      flag=0;
      break;
    }
  }
  if(flag)
    cout<<"None"<<endl;
  return 0;
}


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

using namespace std;

const int N = 15;

int n, m, x;

int c[N], a[N][N];

int main() {

    cin >> n >> m >> x;
    for (int i = 0; i < n; i ++) {
        cin >> c[i];
        for (int j = 0; j < m; j ++) {
            cin >> a[i][j];
        }
    }
    int ans = INT_MAX;
    for (int i = 0; i < (1 << n); i ++) {
        int cost = 0;
        vector <int> level(m, 0);
        for (int j = 0; j < n; j ++) {
            if (i & (1 << j)) {
                cost += c[j];
                for (int k = 0; k < m; k ++) {
                    level[k] += a[j][k];
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < m; j ++) {
            if (level[j] < x) {
                flag = false;
                break;
            }
        }
        if (flag) ans = min(ans, cost);
    }
    cout << ((ans != INT_MAX) ? ans : -1) << '\n';
    return 0;
}


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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

int n;
ll arr[3005];
ll dp[3005][3005];

ll recur(int i, int j)
{
    if(i == j) return arr[i];
    if(i == j-1) return max(arr[i],arr[j]);
    if(dp[i][j] != -1) return dp[i][j];

    return dp[i][j] = max(arr[i]+min(recur(i+2,j),recur(i+1,j-1)),
               arr[j]+min(recur(i+1,j-1),recur(i,j-2)));
}

int main()
{
    FASTIO
    memset(dp,-1,sizeof(dp));
    cin >> n;
    ll sum = 0;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    if(n == 1) cout << arr[0];
    else if(n == 2) cout << max(arr[0],arr[1]) - min(arr[0],arr[1]);
    else
    {
        recur(0,n-1);
        cout << 2*dp[0][n-1] - sum << "\n";
    }
    return 0;
}

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

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    long N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    for(long i = 0; i < N; i++){
        if((i * M / gcd(N, M)) % (N / gcd(N, M)) == 0 && S[i] != T[(i * M / gcd(N, M)) / (N / gcd(N, M))]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << N * M / gcd(N, M) << endl;
}


Measured memory_bytes: 512
n,x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

if a.reduce(:+) == x
  puts n
  exit 0
end

max = 0

a.each.with_index(1) do |num, i|
  if a[0...i].reduce(:+) <= x
    max = i
  end
end

puts max == n ? max-1 : max


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 1e5 + 5;
const int M = 15;

string s;
ll n, dp[N][M];

ll solve(int i, int rem) {
    if (i == n) 
        return rem == 5;
    ll& ret = dp[i][rem];
    if (~ret)
        return ret;

    ret = 0;
    if (s[i] == '?') {
        for (int r = 0; r <= 9; ++r)
            (ret += solve(i + 1, (rem * 10 + r) % 13)) %= MOD;
    } else {
        ret = solve(i + 1, (rem * 10 + s[i] - '0') % 13);
    }

    return ret;
}

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

    cin >> s;

    n = (ll) s.size();

    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;
}


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

namespace ABC125C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long N = ConsoleInput.Long();
            long[] A = ConsoleInput.LongArray();

            long[] gcdRight = new long[N];
            long[] gcdLeft = new long[N];
            gcdLeft[0] = A[0];
            gcdRight[N - 1] = A[N - 1];
            for (int i = 0; i < N-1; i++)
            {
                gcdLeft[i + 1] = Gcd(gcdLeft[i], A[i + 1]);
                gcdRight[N - i - 2] = Gcd(gcdRight[N - i - 1], A[N - i - 2]);
            }

            long ans = gcdRight[1];
            for (int i = 0; i < N - 2; i++)
            {
                ans = Math.Max(ans, Gcd(gcdLeft[i], gcdRight[i + 2]));
            }

            ans = Math.Max(ans, gcdLeft[N - 2]);
            Console.WriteLine(ans);
        }
        
        
        public static long Gcd(long a, long b)
        {
            return b > 0 ? Gcd(b, a % b) : a;
        }
    }
    
    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 27996
fun readIntArray(n: Int): IntArray {
    val arr = IntArray(n)
    var i = 0
    var tmp = 0

    for (c in readLine()!!) {
        if (c == ' ') {
            arr[i] = tmp
            i++
            tmp = 0
        } else {
            tmp *= 10
            tmp += c - '0'
        }
    }
    arr[i] = tmp
    return arr
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aaa = readIntArray(n)
    val bbb = readIntArray(n)
    var ans = 0
    for (k in 29 downTo 0) {
        val t1 = 1 shl k
        val t2 = t1 shl 1
        val t3 = t1 + t2
        val mask = t2 - 1
        val bbbMod = bbb.map { it and mask }.toIntArray()
        bbbMod.sort()
        var tmp = 0
        for (a in aaa) {
            val am = a and mask
            if (am <= t1) {
                val s1 = bbbMod.bisectLeft(t1 - am)
                val s2 = bbbMod.bisectLeft(t2 - am, fromIndex = s1)
                tmp += s2 - s1
            } else {
                val s2 = bbbMod.bisectLeft(t2 - am)
                val s3 = bbbMod.bisectLeft(t3 - am, fromIndex = s2)
                tmp += s2 + n - s3
            }
        }
        ans = ans shl 1
        ans += tmp and 1
    }
    println(ans)
}

fun IntArray.bisectLeft(x: Int, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
    var l = fromIndex
    var r = toIndex
    while (l <= r) {
        val m = (l + r + 1) / 2
        if (this[m] < x) {
            l = m + 1
        } else {
            r = m - 1
        }
    }
    return l
}


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

long long totalXorFrom0 (long long x) {
  long long ret = 0;
  if (x != 0) {
    if ((x % 2) == 0) {
      long long tmp = (x / 2);
      if ((tmp % 2) == 0) {
        ret = x;
      } else {
        ret = (x + 1);
      }
      return ret;
    } else {
      long long tmp = ((x / 2) + 1);
      if ((tmp % 2) == 0) {
        return 0;
      } else {
        return 1;
      }
    }
  } else {
    return 0;
  }
};

long long totalXor(long long A, long long B) {
  if (A == B) {
    return A;
  } else if (A == 0) {
    return totalXorFrom0(B);
  } else {
    return (totalXorFrom0(A - 1) ^ totalXorFrom0(B));
  }
};

int main() {
  long long A, B;
  cin >> A >> B;
  cout << totalXor(A, B) << endl;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long M, long long V, long long P, std::vector<long long> A){
  sort(A.begin(),A.end());
  dump(A);
  ll l=-1,r=A.size()-1;
  while(l+1<r){
    dump(l);
    dump(r);
    ll mid=(l+r)/2;
    ll score = A[mid]+M;
    dump(score);
    ll rank = upper_bound(A.begin(),A.end(),score)-A.begin()-1;
    rank=A.size()-rank;
    if(rank>P){
      l=mid;
      continue;
    }
    dump(rank);
    ll stock = (V-P-mid)*M;
    FOR(i,mid+1,A.size()-(P-1)){
      if(i==mid)continue;
      stock-=max(0LL,min(M,score-A[i]));
    }
    dump(stock);
    if(stock>0){
      l=mid;
      continue;
    }else{
      r=mid;
      continue;
    }
  }
  cout<<A.size()-r<<endl;
}

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int check(char next)
{
	if(next == 'a')
		return 0;
	if(next == 'b')
		return 1;
	if(next == 'c')
		return 2;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t, r;
	cin >> s >> t >> r;
	int turn = 0;
	char next;
	while(1)
	{
		if(turn == 0)
		{
			if(s.size() != 0)
				next = s.front();
			else
			{
				cout << 'A' << endl;
				break;
			}
			s.erase(0, 1);
			turn = check(next);
		}
		else if(turn == 1)
		{
			if(t.size() != 0)
				next = t.front();
			else
			{
				cout << 'B' << endl;
				break;
			}
			t.erase(0, 1);
			turn = check(next);
		}
		else if(turn == 2)
		{
			if(r.size() != 0)
				next = r.front();
			else
			{
				cout << 'C' << endl;
				break;
			}
			r.erase(0, 1);
			turn = check(next);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>

using namespace std;

// 最大公約数を求める
long gcd(long x, long y){
    if (x > y)
        return gcd(y, x);
    
    long m = 1;
    while(m != 0){
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

// 最小公倍数を求める
long lcm(long x, long y){
    return x * y / gcd(x, y);
}

int main() {
  long A,B;
  cin >> A >> B;
  cout <<  lcm(A,B) << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int64_t sum_Digit, multiple_Number, top_Num;
  sum_Digit = 0;
  multiple_Number = 1;
  top_Num = 1;

  vector<int64_t> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    if(A.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  
  for(int i = 0; i < N; i++){
    int64_t X;
    X = A.at(i);
    
    multiple_Number = multiple_Number * X;
        
    int dig1 = 1;
    int dig2 = 0;
    while(X / 10 > 0){
      X = X / 10;
      dig2++;
    }
    top_Num = top_Num * X;
    int64_t top_Num2 = top_Num;
    
    while(top_Num2 / 10 > 0){
      top_Num2 = top_Num2 / 10;
      dig1++;
    }
      
    sum_Digit += dig2;
  
    if(dig1 + sum_Digit - 1 > 18){
      cout << -1 << endl;
      return 0;
    }
  }
  if(multiple_Number > 1000000000000000000) cout << -1 << endl;
  else cout << multiple_Number << endl;
}

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

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

  string s; cin >> s;
  string t = "keyence";

  for(int i = 0; i < s.size(); i++){
    for(int j = i; j < s.size(); j++){
      if(s.substr(0,i) + s.substr(j,s.size()-1) == t){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}


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

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        long res = a[n-1] - a[0];

        int li = 1;
        int ri = n-2;
        int min = a[0];
        int max = a[n-1];
        while(li <= ri) {
            if(Math.abs(max - a[li]) > Math.abs(a[ri] - min)) {
                res+=Math.abs(max-a[li]);
                int tmin = Math.min(min, a[li]);
                int tmax = Math.max(min, a[li]);
                min = tmin;
                max = tmax;
                li++;
            } else {
                res+=Math.abs(a[ri] - min);
                int tmin = Math.min(max, a[ri]);
                int tmax = Math.max(max, a[ri]);
                min = tmin;
                max = tmax;
                ri--;
            }
        }
        System.out.println(res);

    }

}


Measured memory_bytes: 51640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

bool check(string s){
  if(s==""||s=="i"||s=="w") return true;
  bool b=false;
  if((s[0]==s[s.size()-1])&&(s[0]=='i'||s[0]=='w')) b=true;
  if(s[0]=='('&&s[s.size()-1]==')') b=true;
  if(s[0]==')'&&s[s.size()-1]=='(') b=true;
  if(s[0]=='['&&s[s.size()-1]==']') b=true;
  if(s[0]==']'&&s[s.size()-1]=='[') b=true;
  if(s[0]=='{'&&s[s.size()-1]=='}') b=true;
  if(s[0]=='}'&&s[s.size()-1]=='{') b=true;
  return b&&check(s.substr(1,s.size()-2));
}

int main(){

  string s;
  cin>>s;
  int maxSize=0;
  for(int i = 0; i < (1<<(s.size())); i++){
    string ss;
    for(int j = 0; j < s.size(); j++){
      if((i>>j)&1)
	ss+=s[j];
    }
    if(check(ss)){
      bool b=false;
      for(int i = 0; i+2 < ss.size(); i++){
	if(ss.substr(i,3)=="iwi"){
	  b=true;
	  for(int j = 0; j < ss.size(); j++){
	    if(ss[j]=='i'){
	      if(!(j==i||j==i+2)){
		b=false;
		break;
	      }
	    }
	    else if(ss[j]=='w'){
	      if(!(j==i+1)){
		b=false;
		break;
	      }
	    }
	  }
	  break;
	}
      }
      if(b)
	maxSize=max(maxSize,(int)ss.size());
    }
  }
  cout<<maxSize<<endl;
  return 0;
}

Measured memory_bytes: 880
#include <iostream>
#include <algorithm>
using namespace std;
bool BinarySearch(long long a[],long long left,long long right,long long number)
{    
while(left<right)    
{     
   long long middle=(left+right)/2;     
   if(number==a[middle])        
    return true;        
if(number<a[middle])       
     right=middle;        
else if(number>a[middle])      
      left=middle+1;    
}   
 return false;
}
int main()
{   
 long long n,i;  
  cin>>n;  
  long long a[100005];    
for( i=0; i < n; i++)   
 cin>>a[i];    
sort(a,a+n);   
 long long m,num,counts=0;    
cin>>m;    
for(i = 0; i<m; i++)    
{        
cin>>num;        
if(BinarySearch(a,0,n,num))     
       counts++;    
}   
 cout<<counts<<endl;  
 return 0;
}


Measured memory_bytes: 3900
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[2005];
int prm[2005*10],m;
typedef vector<int> vi;
vi fact[2005];
vi rev[2005*10];
bool mark[2005];

int cnt;
bool vis_p[2005*10];
bool vis_v[2005];
void dfs(int v){
  vis_v[v]=true;
  ++cnt;
  for(auto p:fact[v]) if(!vis_p[p]){
    vis_p[p]=true;
    for(auto e:rev[p]) if(!vis_v[e] && !mark[e]){
      dfs(e);
    }
  }
}

int from[2005];
bool ok[2005];
int main(){
  cin>>n;
  REP(i,n){
    scanf("%d",&ar[i]);
  }
  sort(ar,ar+n);
  REP(i,n){
    int tmp=ar[i];
    for(int j=2;j*j<=tmp;++j) if(tmp%j==0){
      while(tmp%j==0) tmp/=j;
      fact[i].pb(j);
    }
    if(tmp>1) fact[i].pb(tmp);
    for(auto e:fact[i]) prm[m++]=e;
  }
  sort(prm,prm+m);
  m=unique(prm,prm+m)-prm;
  REP(i,n){
    for(auto& e:fact[i]){
      e=lower_bound(prm,prm+m,e)-prm;
      rev[e].pb(i);
    }
  }
  REP(i,n) ok[i]=true;

  vi ans;
  REP(i,n){
    dump(i);
    CLR(vis_v);
    CLR(vis_p);
    cnt=i;
    REP(j,n) if(!mark[j] && !vis_v[j] && ok[j]){
      dfs(j);
      dump(j);dump(ar[j]);dump(cnt);
      if(cnt==n){
        ans.pb(ar[j]);
        mark[j]=true;
        break;
      }
    }
    int val=ans.back();
    dump(val);
    REP(j,n) if(!mark[j]){
      if(__gcd(val,ar[j])>1){
        from[j]=i+1;
        ok[j]=true;
      }else if(val<ar[j]){
        ok[j]=false;
      }
    }
  }
  for(auto e:ans) printf("%d\n",e);
  return 0;
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
vector<vector<ll>> dp(3000 + 10, vector<ll>(3000 + 10));
int main(){
    string S, T;
    cin >> S >> T;
    dp[0][0] = S[0] == T[0];
    for(ll i = 1; i < S.size(); i++) dp[i][0] = max(dp[i - 1][0], (ll)(S[i] == T[0]));
    for(ll i = 1; i < T.size(); i++) dp[0][i] = max(dp[0][i - 1], (ll)(S[0] == T[i]));
    for(ll i = 1; i < S.size(); i++){
        for(ll j = 1; j < T.size(); j++){
            if(S[i] == T[j]) dp[i][j] = max(dp[i - 1][j - 1] + 1, max(dp[i - 1][j], dp[i][j - 1]));
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    ll i = S.size() - 1, j = T.size() - 1;
    string ans;
    while(1){
        if(ans.size() == dp[S.size() - 1][T.size() - 1]) break;
        if(dp[i][j] == 0) break;
        if(i && j && dp[i - 1][j - 1] + 1 == dp[i][j] && S[i] == T[j]){
            ans += S[i];
            i--;
            j--;
        }else if(i && dp[i - 1][j] == dp[i][j]){
            i--;
        }else if(j && dp[i][j - 1] == dp[i][j]){
            j--;
        }else if(i == 0){
            if(dp[i][j] == 1){
                ans += S[0];
                break;
            }else{
                j--;
            }
        }else if(j == 0){
            if(dp[i][j] == 1){
                ans += T[0];
                break;
            }else{
                i--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 71168
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char N[5];
    scanf("%s", N);
    if((N[0]==N[1]&&N[1]==N[2])||(N[2]==N[1]&&N[3]==N[2]))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
while
  string =  gets.split(" ")
  list = [string[0], string[1], string[2]]
  if string[1] == '?'
    break
  end
  if string[1] == '+'
    puts string[0].to_i + string[2].to_i
  end
  if string[1] == '-'
    puts string[0].to_i - string[2].to_i
  end
  if string[1] == '*'
    puts string[0].to_i * string[2].to_i
  end
  if string[1] == '/'
    puts string[0].to_i / string[2].to_i
  end
end


Measured memory_bytes: 6872
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int w = iin(), h = iin(), x = iin(), y = iin(), r =iin();
    if (r <= y && y <= (h - r) && r <= x && x <= (w - r)) {
        stout("Yes");
    } else {
        stout("No");
    }
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

main(){
	int n;
	long long ans;
	string s;
	map<string, int> mp;
	ans = 0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		sort(s.begin(),s.end());
		ans += mp[s];
		mp[s]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11136
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}

	vector<int> tb(n);

	for (int i = 0; i < n; i++) {
		tb[a[i]] = i;
	}

	int prev = -1;
	int tmp = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (tb[i] > prev) {
			tmp++;
		}
		else {
			ans = max(ans, tmp);
			tmp = 1;
		}

		prev = tb[i];

		if (i == n - 1) {
			ans = max(ans, tmp);
		}
	}

	cout << n - ans << endl;

	return 0;
}

Measured memory_bytes: 1792