akhauriyash/Code-Regression huggingface dataset:
/* while(!success_achieved())
      work_hard(); 

   code by:aman_ayush
  */
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll inf =0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abs(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
    int n,k;
    cin>>n>>k;
    str s;
    cin>>s;
    int res=0,cnt=0;
    forr(1,n)
    {
        if(s[i]==s[i-1])
         res++;
         else
          cnt++;
    }
    int p=cnt/2;
    res+=2*min(k,p);
    k-=p;
    if((cnt%2))
    {
        if(k>0)
         res++;
    }
    cout<<res<<"\n";
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
using namespace std;
int G[1500000];
long long cnt = 0;
void insertionSort(int*p, int n, int g) {
	for (int i = g; i < n; i++) {
		int v = p[i];
		int j = i - g;
		while (j >= 0 && p[j] > v) {
			p[j + g] = p[j];
			j -= g;
			cnt++;
		}
		p[j + g] = v;
	}
}
void shellSort(int*p, int n) {
	int  x = 0, zlq = n;
	while (zlq>0)
	{
		G[x] = zlq >> 1;
		zlq = zlq >> 1;
		x++;
	}
	x--;
	if (x == 0)
	{
		printf("1\n1\n0\n1\n");
		return;
	}
	for (int i = 0; i < x; i++)insertionSort(p, n, G[i]);
	printf("%d\n", x);
	for (int i = 0; i < x; i++)printf("%d ", G[i]);
	printf("\n");
}
int main()
{
	int n;
	int*seq;
	scanf("%d", &n);
	seq = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", &seq[i]);

	shellSort(seq, n);
	if (n == 1)return 0;
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++)
		printf("%d\n", seq[i]);

	return 0;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
const int maxn = 30;
int bin[maxn];
int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
	bin[0] = 1;
	long double ans = 0;
	for(int i = 1 ; i <= 30 ; i++) bin[i] = bin[i-1] * 2;
	for(int i = 1 ; i <= n ; i++)
	{
		for(int j = 28 ; j >= 0 ; j--)
		{
			if(1LL * i * bin[j] < k)
			{
				ans += (long double) 1 / (bin[j+1]);
				break;
			}
		}
	}
	if(n >= k) ans += ((long double)n - (long double )k + (long double)1);
	printf("%.10Lf\n",ans / (long double)n - 1e-10);
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string N;
  
  cin >> N;

  if((N[0]==N[1])&&(N[1]==N[2]))
  {
    cout <<"Yes" << endl;
  }
  else if((N[1]==N[2])&&(N[2]==N[3]))
  {
    cout <<"Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}



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

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned long ul;

int main() {
    int n; cin>>n;
    vector<int> v;
    CIN_VEC(v,n);

    int ans = 0;
    for(int i=1; i<v.size(); i++) {
        if(v[i]!=-1 && v[i-1]==v[i]) {
            v[i]=-1;
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,T,c,t;cin>>n>>T;
  lvector v;
  rep(i,n) {
    cin>>c>>t;
    if(t<=T) v.emplace_back(c);
  }
  if(v.size()==0) puts("TLE");
  else {
    ll ans=*min_element(v.begin(),v.end());
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a<<" "<<b<<" "<<3*c-a-b<<" "<<endl;
    cout<<4*c-2*a-b<<" "<<c<<" "<<2*a+b-2*c<<" "<<endl;
    cout<<a+b-c<<" "<<2*c-b<<" "<<2*c-a<<" "<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[2 * n];
        for(int i = 0; i < 2 * n; i++){
            cin >> a[i];
        }
        sort(a, a + 2 * n);
        int ans = 0;
        for(int i = 0; i < 2 * n; i += 2){
            ans += a[i];
        }
        cout << ans << '\n';
    }
}

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

#define ll long long

int foo(int A){
	int ct = 0;
	for (int j = 1; j*j <= A; j ++){
		if (A % j == 0){
			int f1 = j, f2 = A / j;
			if (f1 == f2) ct += 1;
			else ct += 2;
		}
	}
	return ct;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	ll result = 0;
	for (int i = 1; i <= N - 1; i ++){
		result += foo(i);
	}
	cout << result << "\n";

}

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

long long n, k, q;
vector<long long> x, rx;
vector<vector<long long>> memo, rmemo, sum, rsum;

int main() {
  cin >> n >> k;
  x.resize(n);
  for (auto &p : x) cin >> p;
  rx = x;
  reverse(rx.begin(), rx.end());
  for (auto &p : rx) p = -p;
  auto calcmemo = [](vector<long long> &v) {
    vector<vector<long long>> res(30, vector<long long>(n + 1, n));
    for (int i = 0; i < n; ++i)
      res[0][i] = lower_bound(v.begin(), v.end(), v[i] + k) - v.begin();
    for (int i = 1; i < 30; ++i)
      for (int j = 0; j < n; ++j) res[i][j] = res[i - 1][res[i - 1][j]];
    return res;
  };
  auto calcsum = [](vector<vector<long long>> &v, bool reversed = 0) {
    vector<vector<long long>> res(30, vector<long long>(n + 1, 0));
    if (reversed)
      for (int i = 1; i <= n; ++i) res[0][i] = v[0][i];
    else
      for (int i = 0; i < n; ++i) res[0][i] = v[0][i] * (v[0][i] != n);
    for (int i = 1; i < 30; ++i)
      for (int j = 0; j <= n; ++j)
        res[i][j] = res[i - 1][j] + res[i - 1][v[i - 1][j]];
    return res;
  };
  memo = calcmemo(x);
  rmemo = calcmemo(rx);
  for (auto &v : rmemo) {
    reverse(v.begin(), v.end());
    for (auto &p : v) p = n - p;
  }
  sum = calcsum(memo);
  rsum = calcsum(rmemo, 1);
  cin >> q;
  for (int i = 0; i < q; ++i) {
    long long x, y, z, now = 0;
    cin >> x >> y;
    --x;
    // x
    z = x;
    for (int j = 29; j >= 0; --j)
      if (memo[j][z] < y) {
        now -= sum[j][z];
        z = memo[j][z];
      }
    // y
    z = y;
    for (int j = 29; j >= 0; --j)
      if (x < rmemo[j][z]) {
        now += rsum[j][z];
        z = rmemo[j][z];
      }
    cout << now + y - x << endl;
  }
  return 0;
}

Measured memory_bytes: 195472
use std::io::Read;

fn main() {
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).unwrap();
	let s = s.trim();
	let half = s.len()/2;
	let first_half = &s[..half];
	let second_half = &s[half..];
	let second_half: String = second_half.chars().rev().collect();

	let mut count = 0;

	for (a, b) in first_half.chars().zip(second_half.chars()) {
		if a != b {
			count += 1;
		}
	}

	println!("{:?}", count);
}


Measured memory_bytes: 4352
n = int(input())
card = [input().split() for _ in range(n)]

taro = 0
hanako = 0

for i in range(n):
    taro_card = card[i][0]
    hanako_card = card[i][1]
    
    if taro_card == hanako_card:
        taro += 1
        hanako += 1
        continue
    if taro_card > hanako_card:
        taro += 3
    else:
        hanako += 3
    
print(taro, hanako)


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) { os << p.first << " " << p.second; return os; }

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; }return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int a, b, k; cin >> a >> b >> k;
	rep(i, 0, k) {
		if (i & 1) {
			a += b / 2;
			b /= 2;
		}
		else {
			b += a / 2;
			a /= 2;
		}
	}
	cout << a << " " << b << endl;

	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (int NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  int n;
  cin>>n;
  int cnt=0;
  vector<int> c(n);
  vector<int> v(n);
  REP(i,n)cin>>c.at(i);
  REP(i,n)cin>>v.at(i);
  REP(i,n){
    if(c.at(i)>v.at(i))cnt+=c.at(i)-v.at(i);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
k=int(input())

q=[1,2,3,4,5,6,7,8,9]
c=0
for i in range(k):
    num=q[c]
    if num%10>0:
        q.append(num*10+num%10-1)
    q.append(num*10+num%10)
    if num%10<9:
        q.append(num*10+num%10+1)
    c+=1
print(q[k-1])

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

int n,M[105][105],d[105],f[105],tt,P[105],nt[105];

int next(int u){
	for(int v=nt[u];v<n;v++){
		nt[u]=v+1;
		if(M[u][v]){
			return v;
		}
	}
	return -1;
}
void dfs_visit(int r){
	for(int i=0;i<n;i++){
		nt[i]=0;
	}
	stack<int> s;
	s.push(r);
	P[r]=1;
	tt++;
	d[r]=tt;
	while(s.size()!=0){
		int u= s.top();
		int v=next(u);
		if(v!=-1){
			if(P[v]==0){
				P[v]=1;
				tt++;
				d[v]=tt;
				s.push(v);
			}
		}
		else{
			P[u]=2;
			tt++;
			f[u]=tt;
			s.pop();
		}
	}
}

void dfs(){
	for(int i=0;i<105;i++){
		d[i]=f[i]=P[i]=0;
	}
	tt=0;
	for(int i=0;i<n;i++){
		if(P[i]==0){
			dfs_visit(i);
		}
	}
	for(int i=0;i<n;i++){
		printf("%d %d %d\n",i+1,d[i],f[i]);
	}
}

int main() {
	cin>>n;
	int u,k,v;
	for(int i=0;i<105;i++){
		for(int j=0;j<105;j++){
			M[i][j]=0;
		}
	}
	for(int i=0;i<n;i++){
		cin>> u>>k;
		u--;
		for(int j=0;j<k;j++){
			cin>>v;
			v--;
			M[u][v]=1;
		}
	}
	dfs();
	return 0;
}


Measured memory_bytes: 3280
object Main extends App {
	val Array(k, n) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val a = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val b = new Array[Int](n)

	for(i<-0 until n-1){
		b(i) = k - (a(i+1) - a(i))
	}

	b(n-1) = a(n-1) - a(0)

	println(b.min)
}

Measured memory_bytes: 54544
n,m = map(int, input().split())
l = []
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
for i in range(0,9999):
    if len(str(i)) != n:
        continue
    ok=True
    for tmp in l:
        if str(i)[tmp[0]-1] != str(tmp[1]):
            ok=False
    if ok:
        print(i)
        exit()
print(-1)

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

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

	int sum = a % 10;
	if ((sum >= b % 10) && (0<b%10)) { sum = b % 10; }
	if ((sum >= c % 10) && (0<c%10)) { sum = c % 10; }
	if ((sum >= d % 10) && (0<d%10)) { sum = d % 10; }
	if ((sum >= e % 10) && (0<e%10)) { sum = e % 10; }

	if (sum == a % 10) {
		for (int i = 0; e % 10 != 0; i++) {
			e += 1;
		}
		b += e;
		for (int i = 0; b % 10 != 0; i++) {
			b += 1;
		}
		c += b;
		for (int i = 0; c % 10 != 0; i++) {
			c += 1;
		}
		d += c;
		for (int i = 0; d % 10 != 0; i++) {
			d += 1;
		}
		a += d;

		cout << a << endl;
	}
	else if (sum == b % 10) {
		for (int i = 0; e % 10 != 0; i++) {
			e += 1;
		}
		a += e;
		for (int i = 0; a % 10 != 0; i++) {
			a += 1;
		}
		c += a;
		for (int i = 0; c % 10 != 0; i++) {
			c += 1;
		}
		d += c;
		for (int i = 0; d % 10 != 0; i++) {
			d += 1;
		}
		b += d;

		cout << b << endl;
	}
	else if (sum == c % 10) {
		for (int i = 0; e % 10 != 0; i++) {
			e += 1;
		}
		a += e;
		for (int i = 0; a % 10 != 0; i++) {
			a += 1;
		}
		b += a;
		for (int i = 0; b % 10 != 0; i++) {
			b += 1;
		}
		d += b;
		for (int i = 0; d % 10 != 0; i++) {
			d += 1;
		}
		c += d;

		cout << c << endl;
	}
	else if (sum == d % 10) {
		for (int i = 0; e % 10 != 0; i++) {
			e += 1;
		}
		a += e;
		for (int i = 0; a % 10 != 0; i++) {
			a += 1;
		}
		b += a;
		for (int i = 0; b % 10 != 0; i++) {
			b += 1;
		}
		c += b;
		for (int i = 0; c % 10 != 0; i++) {
			c += 1;
		}
		d += c;

		cout << d << endl;
	}
	else if (sum == e % 10) {
		for (int i = 0; a % 10 != 0; i++) {
			a += 1;
		}
		b += a;
		for (int i = 0; b % 10 != 0; i++) {
			b += 1;
		}
		c += b;
		for (int i = 0; c % 10 != 0; i++) {
			c += 1;
		}
		d += c;
		for (int i = 0; d % 10 != 0; i++) {
			d += 1;
		}
		e += d;

		cout << e << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map &:to_i
r, s, p = gets.split.map &:to_i
ts = gets.chomp.split("")

arr = {}

ts.each_with_index{ |t,i|
	ind = i % k
	
	if arr[ind] == nil then
		arr[ind] = []
	end
	
	arr[ind] << t
}

point = 0

arr.each{ |k,v|
	before = nil
	v.each{ |t|
		if before == t then
			before = nil
		else
			before = t
			if t == 'r' then
				point += p
			elsif t == 's' then
				point += r
			else
				point += s
			end
		end
	}
}

puts point

Measured memory_bytes: 20988
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

class UnionFind
{
public:
    UnionFind(int size)
    : p(size, -1)
    {}

    int find(int x)
    {
        if (p[x] < 0) return x;
        else return p[x] = find(p[x]);
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    void unite(int x, int y)
    {
        int rx = find(x);
        int ry = find(y);
        if (rx == ry) return;

        if (p[rx] > p[ry]) swap(rx, ry);
        p[rx] += p[ry];
        p[ry] = rx;
    }

    vs32 p;
};

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

    int n, m;
    cin >> n >> m;

    vs32 p(n);
    rep (i, n)
    {
        cin >> p[i];
        --p[i];
    }

    UnionFind uf(n);
    rep (i, m)
    {
        int x, y;
        cin >> x >> y;
        --x, --y;
        uf.unite(x, y);
    }

    int ans = 0;
    rep (i, n)
    {
        if (uf.same(p[i], i)) ++ans;
    }

    cout << ans << "\n";
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int m;
int d[252521];
int t[252521];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",d+i);
  scanf("%d",&m);
  REP(i,m)scanf("%d",t+i);
  sort(d,d+n);
  sort(t,t+m);
  int head = 0;
  REP(i,m){
    while(head<n && d[head]!=t[i])head++;
    if(head==n){
      puts("NO");
      return 0;
    }
    head++;
  }
  puts("YES");
  return 0;
}


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

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

if(a < b)
{
   if(b < c)
   {
     cout << a << " " << b << " " << c << endl;
   }
   else
   {
     if(c < a)
     {
       cout << c  << " " << a << " " << b << endl;
     }
     else
     {
       cout << a << " " << c << " " << b << endl;
     }
   }
}
else
{
   if(a < c)
   {
     cout << b << " " << a << " " << c << endl;
   }
   else
   {
     if(c < b)
     {
       cout << c << " " << b << " " << a << endl;
     }
     else
     {
       cout << b << " " << c << " " << a << endl;
     }
   }
}

return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>

int main(){

int max=0,ans=0;
int A[3];
for (int i = 0; i < 3; i++){
  scanf("%d",&A[i]);
  if (max<A[i]){ max=A[i];}
}

for (int i = 0; i < 3; i++){
  while (A[i]+2<=max){
    A[i]+=2;
    ans++;
  }
}

int diff=max*3-A[0]-A[1]-A[2];
if(diff==2)
{
  ans+=1;
}else if(diff==1)
{
  ans+=2;
}

printf("%d",ans);

return 0;

}

Measured memory_bytes: 1688
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int m = 1_000_000_007;
        int N = sc.nextInt();
        long[] A = new long[(int) N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        long res = 0;
        for (int d = 0; d < 60; d++) {
            long n0 = 0, n1 = 0;
            for (int i = 0; i < N; i++) {
                if ((A[i] & (1L << d)) != 0) {
                    n1++;
                } else {
                    n0++;
                }
            }
            long tmp = (1L << d) % m;
            long n = n0 * n1 % m;
            tmp = tmp * n;
            res += tmp;
            res %= m;
        }
        out.println(res);
        out.flush();
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 30552
#include <stdio.h>

int main() {
  long n, a, b, i, ans = 0;
  scanf("%ld %ld %ld", &n, &a, &b);
  
  if (a == 0) {
    printf ("0");
  	return(0);
  }
  
  ans = n/(a+b) * a;
  if (n%(a+b) < a)
    ans += n%(a+b);
  else if (n%(a+b) >= a)
    ans += a;
  
  printf("%ld", ans);
  return(0);
}

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

using namespace std;

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

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N)
    cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, K)
    ans += p[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn make_divisors(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in 1.. {
        if i*i > n {
            break;
        }
        if i*i == n {
            res.push(i);
        } else if n%i == 0 {
            res.push(i);
            res.push(n/i);
        }
    }
    res
}

fn solve() {
    let n = get!(usize);

    let mut count = 0usize;
    for e in make_divisors(n).into_iter().skip(1) {
        let mut n = n;
        while n % e == 0 {
            n /= e;
        }
        if n%e ==1 {
            count += 1;
        }
    }
    for e in make_divisors(n-1).into_iter().skip(1) {
        let mut n = n;
        while n % e == 0 {
            n /= e;
        }
        if n%e ==1 {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 8572
x=[]
y=[]


for i in range (4):
    A=int(input())
    x.append(A)
x1=sorted(x,reverse=True)

for j in range (2):
    B=int(input())
    y.append(B)
y1=sorted(y,reverse=True)
   
   
print(x1[0]+x1[1]+x1[2]+y1[0])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 10;
char s[maxn];
int vis[20];
void dfs(int dps, int fin, int mx) {
    if (dps == fin) {
        cout << s << '\n';
    }
    else {
        for (int i = 0; i <= mx; i++) {
            s[dps] = 'a' + i;
            dfs(dps + 1, fin, i == mx ? mx + 1 : mx);
        }
    }
}
int main() {
    int n;  cin >> n;
    s[n] = 0;
    dfs(0, n, 0);
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>

using namespace std;

const int MN = 110;
const int INF = 1<<29;
int sd[22][MN][MN];
int dist[MN][MN];
bool solve() {
	int n, m, C, s, g;
	cin >> n >> m >> C >> s >> g; s--; g--;
	if (!n) return false;
	for (int c = 0; c < C; c++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				sd[c][i][j] = INF;
			}
			sd[c][i][i] = 0;
		}
	}
	for (int i = 0; i < m; i++) {
		int x, y, d, c;
		cin >> x >> y >> d >> c; x--; y--; c--;
		d = min(d, sd[c][x][y]);
		sd[c][x][y] = sd[c][y][x] = d;
	}

	for (int c = 0; c < C; c++) {
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					sd[c][i][j] = min(sd[c][i][j], sd[c][i][k]+sd[c][k][j]);
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dist[i][j] = INF;
		}
		dist[i][i] = 0;
	}
	int p[22];
	for (int i = 0; i < C; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < C; i++) {
		static int cost[20200];
		vector<int> qv, ev;
		qv.push_back(0);
		for (int j = 0; j < p[i]-1; j++) {
			int x;
			cin >> x;
			qv.push_back(x);
		}
		qv.push_back(20199);
		for (int j = 0; j < p[i]; j++) {
			int x;
			cin >> x;
			ev.push_back(x);
		}
		cost[0] = 0;
		for (int j = 1; j <= p[i]; j++) {
			for (int l = qv[j-1]+1; l <= qv[j]; l++) {
				cost[l] = cost[l-1] + ev[j-1];
			}
		}
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (sd[i][j][k] == INF) continue;
				dist[j][k] = min(dist[j][k], cost[sd[i][j][k]]);
			}
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
	
	if (dist[s][g] == INF) dist[s][g] = -1;
	cout << dist[s][g] << endl;
	return true;
}

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

Measured memory_bytes: 4188
n = int(input())
a = list(map(int, input().split()))
ball = [0]*n
for i in range(n, 0, -1):
    cnt = 0
    for j in range(i * 2, n + 1, i):
        cnt += ball[j-1]
    cnt %= 2
    if cnt != a[i - 1]:
        ball[i - 1] = 1
print(ball.count(1))
for i in range(0, n):
    if ball[i] == 1:
        print(i+1, end=" ")

Measured memory_bytes: 7148
A,B,C,X,Y = map(int,input().split())

answer = 10**18
for c in range(10**5+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a,0)*A
  cost += max(b,0)*B
  if answer > cost:
    answer = cost
print(answer)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Integer> list = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextInt())
            .collect(Collectors.toList());
        final int[] array = new int[n];
        if (n % 2 == 0) {
            final int all = list.stream().reduce((a, b) -> a ^ b).orElse(0);
            for (int i = 0; i < n; i++) {
                array[i] = all ^ list.get(i);
            }
        } else {
            final int all = list.stream().limit(n - 1).reduce((a, b) -> a ^ b).orElse(0);
            for (int i = 0; i < n - 1; i++) {
                array[i] = all ^ list.get(i);
            }
            array[n - 1] = all;
        }

        final String answer = Arrays.stream(array).mapToObj(Integer::toString).collect(Collectors.joining(" "));
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 66144
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

    if (N < 10) {
        cout << N << endl;
    }
    else if (10 <= N && N < 100) {
        cout << 9 << endl;
    }
    else if (100 <= N && N < 1000) {
        cout << 9 + (N - 99) << endl;
    }
    else if (1000 <= N && N < 10000) {
        cout << 9 + 900 << endl;
    }
    else if (10000 <= N && N < 100000) {
        cout << 9 + 900 + (N - 9999);
    }
    else {
        cout << 9 + 900 + 90000 << endl;
    }

   
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(a==b)
		if(a!=c)
		{
			cout<<"Yes";
			return 0;
		}
	if(a==c)
		if(a!=b)
		{
			cout<<"Yes";
			return 0;
		}
	if(b==c)
		if(b!=a)
		{
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
}

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

using namespace std;

int main(){
  int K;
  cin >> K;
  
  int t = 0;
  for(int i = 1; i <= 360; i++){
    if(K * i % 360 == 0){
      t = i;
      break;
    }
  }
  
  cout << t << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int x,y;
    scanf("%d %d", &x,&y);
    if(x % y == 0){
        printf("-1");
        return 0;
    }
    else{
        int i;
        for(i=2;i<1000000000;i++){
            if( (x*i) % y != 0){
                printf("%d", x*i);
            return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;

    long double pi = 3.141592;
    int R;  cin >> R;

    cout << 2*pi*R <<endl;
    return 0;
}


Measured memory_bytes: 3812
#include<iostream>
using namespace std;
int main(){
int a=0,b=0,c=0,i,val,tmp_a,tmp_b;
for(i=0;i<10;i++){
cin >> val;
if(val>a){
tmp_a=a;
a=val;
tmp_b = b;
b=tmp_a;
c=tmp_b;
}else if(val>b){
tmp_a = b;
b = val;
c = tmp_a;
}else if(val>c){
c=val;
}
}
cout << a << endl;
cout << b << endl;
cout << c << endl;
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int w[n];
    rep(i, 0, n) cin >> w[i];
    int sum = 0;
    rep(i, 0, n) sum += w[i];
    int ans =INF;
    rep(i, 0, n) {
        int sum1 = 0;
        int sum2 = 0;
        rep(j, 0, i) sum1 += w[j];
        sum2 = sum - sum1;
        ans = min(ans, abs(sum1 - sum2));
    }
    cout << ans << endl;
    return 0;
}


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

int solve(){
  int k, s; cin >> k >> s;
  int ans=0;
  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      int s_xy = s-x-y;
      if(0<=s_xy && s_xy<=k)  ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int n,m,x,i;
set<int>s;
int dp[100010];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(i=0;i<m;++i){
		cin>>x;
		s.insert(x);
	}
	dp[0]=1;
	for(int i=1;i<=n;++i){
		if(s.find(i)!=s.end())
			continue;
		for(int j=i-1;j>=i-2;--j)
			dp[i]+=dp[j];
		dp[i]%=1000000007;
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a < c && a > b) || (b > c  &&  a > b) || (a > c && a < b)|| (b < c  &&  a < b)){
        printf("No");
    }else{
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        var n1 = sc.nextInt();
        List<String> sList = new ArrayList<>();
        for (int i = 1; i <= n1; i++) {
            sList.add(sc.next());
        }

        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for (String s : sList){
            if (s.equals("AC")) {
                ac++;
            } else if (s.equals("WA")) {
                wa++;
            } else if (s.equals("TLE")) {
                tle++;
            } else if (s.equals("RE")) {
                re++;
            }
        }

        p("AC x " + ac);
        p("WA x " + wa);
        p("TLE x " + tle);
        p("RE x " + re);
    }

    static void p(String s) { System.out.println(s); }
}


Measured memory_bytes: 63416
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(var) var.begin(), var.end()
#define vi vector<int>
int const MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i = 1; i <= 100*100; i++){
        int c = floor((double)i*0.08);
        int d = floor((double)i*0.1);
        if(c == a && d == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
template<typename T>
vector<T> divisor(T N) {
    vector<T> res;
    for(T i = 1; i * i <= N; i++){
        if(N % i == 0){
            res.push_back(i);
            if(i * i != N)res.push_back(N / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}

int A[200010];
int mp[2000100];
int main() {
    int N;
    cin >> N;
    rep(i, N){
        cin >> A[i];
        mp[A[i]]++;
    }
    int ans = 0;
    rep(i,N){
        if(mp[A[i]] > 1)continue;
        bool ok = true;
        mp[A[i]]--;
        auto v = divisor(A[i]);
        for(auto &p: v){
            if(mp[p] > 0){
                ok = false;
                break;
            }
        }
        /*
        for(int j = 1; j * j <= A[i]; j++){
            if(A[i] % j == 0){
                if(mp[j] > 0){
                    ok = false;
                    break;
                }
                if(mp[A[i]/j] > 0){
                    ok = false;
                    break;
                }
            }
        }*/
        mp[A[i]]++;
        if(ok)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8196
N,W=map(int,input().split())
w=[0 for i in range(N+1)]
v=[0 for i in range(N+1)]
for i in range(1,N+1):
  w[i],v[i]=map(int,input().split())
N_max=max(v[i] for i in range(N+1))
INF=float('inf')
dp=[[INF for i in range(N*N_max+1)]for j in range(N+1)]
dp[0][0]=0
for i in range(1,N+1):
  for j in range(N*N_max+1):
    if v[i]<=j:
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
    else:
      dp[i][j]=dp[i-1][j]
ans=0
for i in range(1,N*N_max+1):
  if dp[N][i]<=W:
    ans=i
print(ans)



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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N;

  CIN(N);

  pair< int, int > A[N];

  int a;
  for (int i = 0; i < N; i++) {
    CIN(a);

    A[i] = { a, i };
  }

  sort(A, A + N);

  for (int i = 0; i < N; i++) {
    cout << A[i].second + 1 << " ";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a[5];
  int k;
  for(int i=0;i<5;i++) cin >> a[i];
  cin >> k;

  int mx = *max_element(a,a+5);
  int mn = *min_element(a,a+5);

  if(mx - mn > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
H = H[::-1]
flag = True
for i in range(N-1):
    if H[i+1] > H[i]:
        H[i+1] -= 1
    if H[i+1] > H[i]:
        flag = False
        break
    
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14396
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from itertools import accumulate

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,Q= map(int, sys.stdin.readline().split())
    S = sys.stdin.readline().rstrip()
    l= [list(map(int,list(sys.stdin.readline().split()))) for i in range(Q)]
    # 累積和
    flg = []
    for i in range(N-1):
        tmp_S = S[i:i+2] #２文字ずつ
        if tmp_S == "AC":
            flg.append(1)
        else:
            flg.append(0)

    flg2 = [0] + flg
    flg2 = list(accumulate(flg2)) #accumurateで累積和[0, 1, 1, 2, 2, 2, 3, 3]

    for e in l:
        print(flg2[e[1]-1] - flg2[e[0]-1]) #累積和から順番で引っ張ってくる

Measured memory_bytes: 35280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int result =0;
		for (int i=0;i<S.length();i++) {
			if (S.charAt(i)=='+') {
				result++;
			} else {
				result--;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int S=Integer.parseInt(br.readLine());
		int h=S/3600;
		int m=(S%3600)/60;
		int s=(S%3600)%60;
		System.out.println(h+":"+m+":"+s);
	}

}



Measured memory_bytes: 24424
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            string[] Reader = ReadLine().Split(' ');

            List<int> Numbers = new List<int>();

            for (int loop = 0; loop < Reader.Length; loop++) Numbers.Add(int.Parse(Reader[loop]));

            Numbers.Sort((a, b) => a - b);

            if ((Numbers[0] == Numbers[1] && Numbers[1] != Numbers[2]) || (Numbers[1] == Numbers[2] && Numbers[1] != Numbers[0])) WriteLine("Yes");
            else WriteLine("No");
        }

    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value) 
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion
    }
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"
#define FR(var, max) for(int var = 0; i < (max); ++i)
using namespace std;
using ll = long long;
using l = long;
using vi = vector<int>;
using vl = vector<l>;
using vll = vector<ll>;
using vvl = vector<vector<l>>;
using vvll = vector<vector<ll>>;
using pll = pair<ll, ll>;

int main()
{
    string s, tmp; cin >> s;
    bool lm = false, rm = false;
    for (int i = 1; i <= 4; ++i) {
        tmp += s[i - 1];
        if (i % 2 == 0) {
            int n = atoi(tmp.c_str());
            if (n <= 12 && n >= 1 && i == 2) lm = true;
            if (n <= 12 && n >= 1 && i == 4) rm = true;
            tmp = "";
        }
    }
    if (lm && rm) cout << "AMBIGUOUS";
    else if (lm && !rm) cout << "MMYY";
    else if (!lm && rm) cout << "YYMM";
    else cout << "NA";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int ans=0;
  cin >> s;
  
  if(s[0]=='1') ans++;
  if(s[1]=='1') ans++;
  if(s[2]=='1') ans++;
  cout <<  ans << endl;
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, k;
    cin>>n>>k;
    if(k==1){
        cout<<"0"<<endl;
    }
    else{
        cout<<(1+n-k)-1;
    }
    return 0;
}

Measured memory_bytes: 256