akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    auto N = next<int>();
    vector<int> point(N, 0);
    times(N * (N - 1) / 2, i) {
        auto A = next<int>() - 1, B = next<int>() - 1, C = next<int>(), D = next<int>();
        if(C > D) {
            point[A] += 3;
        } else if(C < D) {
            point[B] += 3;
        } else {
            point[A]++;
            point[B]++;
        }
    }
    vector<int> point_(N, 0), rank(N);
    times(N, i) point_[i] = point[i];
    sort(all(point_), greater<int>());
    int p_ = 0;
    #ifdef debug
        times(N, i) cout << point[i] ln;
        cout ln;
        times(N, i) cout << point_[i] ln;
        cout ln;
    #endif
    times(N, i) {
        int p = point_[i];
        if(p == p_) continue;
        p_ = p;
        times(N, j) {
            if(p == point[j]) {
                rank[j] = i + 1;
            }
        }
    }
    times(N, i) cout << rank[i] ln;

    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n, k;
const ll MOD = 1e9 + 7;
ll dp[2100][2100];

int main() {
	cin >> n >> k;
	dp[0][n] = 1;
	for (int i = 1; i <= k; ++i) {
		dp[i][n - i] = dp[i - 1][n - i] + dp[i - 1][n - i + 1];
		for (int j = n - i - 1; j >= 0; --j)
			dp[i][j] = (dp[i - 1][j] + dp[i][j + 1]) % MOD;
	}
	ll ans = (dp[k][0] - dp[k - 1][0] + MOD) % MOD;
	int cnt = max(0, n - k - 1);
	for (int i = 0; i < cnt; ++i)
		ans = (ans * 2) % MOD;
	cout << ans << "\n";
	return 0;
}




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

#define judge(x) ((x)!=0)?1:0
int main(void)
{
	int N, D;
	int k;

	cin >> N >> D;

	k = (N / (2 * D + 1)) + (judge(N % (2 * D + 1)));
	cout << k << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
 
    String[] strAry = str.split(" ");
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
 
    System.out.println(x*y +" "+ 2*(x+y));
  }
}

Measured memory_bytes: 24392
#include<stdio.h>
     
    int main(){
      char a;
      scanf("%c", &a);
     
      if((a >= 'a') && (a <= 'z')) {
        printf("a");
      }else if((a >= 'A') && (a <= 'Z')) {
        printf("A");
      }
     
      return 0;
    }

Measured memory_bytes: 1584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(int a, int b, int c) {
    int s,t;
    s = b;
    t = a;
    while (!(s==0)) {
        int tmp = t%s;
        t = s;
        s = tmp;
    }
    if (c%t == 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    int a,b,c;

    gettimeofday(&start,NULL);

    std::cin >> a >> b >> c;
    solve(a, b, c);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int a, b, t;
  cin >> a >> b >> t;
  cout << b * (t / a) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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


int main(){
int n,m,x;
cin>>n>>m>>x;
int ans=1000000000;

int c[n+1];
int ks[n+1][m+1];
for(int i=1;i<=n;i++){
	cin>>c[i];
	for(int j=1;j<=m;j++){
cin>>ks[i][j];
	}
}



for(int bit=0;bit<(1<<n);++bit){
	int cnt=0;
	int val[m+1];
rep(j,m){
	val[j]=0;
}

for(int k=0;k<=n-1;k++){
if (bit & (1 << k)){
cnt+=c[k+1];
rep(l,m){
	val[l]+=ks[k+1][l];
}
}

}


int can=1;
rep(i,m){
	if(val[i]<x)can=0;
}
if(can)ans=min(ans,cnt);


}

if(ans==1000000000)cout<<-1<<endl;
else cout<<ans<<endl;
}



Measured memory_bytes: 3588
using System;
 
class main
{
	static void Main(){
		string s;
		int n = 1000001;
		int m, count;
		int[] p = new int[n];
		p[0] = 1;
		p[1] = 1;
		for (int i = 2; i < 1000; ++i){
			if(p[i] == 1) continue;
			for (int j = i * 2; j < n; j += i)
				p[j] = 1;
		}
		while((s = Console.ReadLine()) != null){
			m = int.Parse(s);
			count = 0;
			for (int i = 0; i <= m; i++)
				if (p[i] == 0) count++;
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 12916
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,l;
  cin>>n>>l;
  vector<string> data(n);
  for(int i=0;i<n;i++){
    cin>>data[i];
  }
  sort(data.begin(),data.end());
    for(int i=0;i<n;i++){
    cout<<data[i];
  }
}

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

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

using namespace std;
using namespace __gnu_pbds;
typedef tree<signed, null_type, less_equal<signed>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//find_by_order();
//order_of_key();
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;


//MODULAR ARITHMATIC
const int mmod = 1000000007;

int add(int a, int b, int m=mmod) {
	return (a%m + b%m)%m;
}

int sub(int a, int b, int m=mmod) {
    return (a%m - b%m + m)%m;
}

int mul(int a, int b, int m=mmod) {
	return ((a%m) * (b%m) % m);
}

int pwr(int a, int b, int m=mmod) {
    a %= m;
    int r = 1;
    while (b > 0) {
		if (b&1) r = mul(r, a);
		b >>= 1;
		a = mul(a, a);
    }
    return r;
}

int inv(int a, int m=mmod) {
	return pwr(a, m-2, m);
}

ii norm(int a, int b) {
	int g = __gcd(a, b);
	a /= g, b /= g;
	if (a == 0) b = 1;
	if (b == 0) a = 1;
	if (a < 0) a = -a, b = -b;
	return {a, b};
}

ii inv(ii p) {
	return norm(-p.second, p.first);
}

int pw[200010];

int32_t main() {
	FAST_IO;
	
		int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	
	int ans = 0;
	map<ii, int> cnt, vis;
	
	for (int i = 0; i < n; i++) {
		if (a[i] == 0 && b[i] == 0) ans++;
		else {
			ii p = norm(a[i], b[i]);
			cnt[p]++;
		}
	}
	int tt = 1;
	for (auto pp: cnt) {
		ii p = pp.first, q = inv(p);
		if (vis[p]) continue;
		tt = mul(tt, sub(add(pwr(2, cnt[p]), pwr(2, cnt[q])), 1));
		vis[p] = vis[q] = 1;
	}
	
	ans = add(ans, tt);
	ans = sub(ans, 1);
	cout << ans << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 56584
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (double i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> p(N), sum(N + 1, 0);
    vector<double> P(1001, 0);

    rep(i, N) {
        cin >> p[i];
        sum[i + 1] = sum[i] + p[i];
    }

    int m = 0;
    int index = 0;
    repd(i, K, N + 1) {
        if (m < sum[i] - sum[i - K]) {
            m = sum[i] - sum[i - K];
            index = i - K;
        }
    }

    double ans = 0;
    repd(i, 1, 1001) {
        repd(j, 1, i + 1) {
            P[i] += j / i;
        }
    }

    repd(i, index, index + K) {
        ans += P[p[i]];
    }

    cout << fixed << setprecision(11) << ans << endl;
    return 0;
}

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

using namespace std;

vector<long long> enum_divisors(long long N) {
    vector<long long> res(N);
    for (long long i = 1; i <= N; ++i) {
        for (long long j = 1; j*i <= N; j++)
        {
            res.at(i*j-1)++;
        }
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    long long answer = 0;
    const auto & res = enum_divisors(N);
    for (int i = 1; i < N+1; i++)
    {
        answer += res.at(i-1)*(i);
    }
    cout << answer;
}

Measured memory_bytes: 81256
n,k=map(int,input().split())
x=list(map(int,input().split()))
a=[]
for i in range(n-k+1):
    a1=abs(x[i])+abs(x[i+k-1]-x[i])
    a2=abs(x[i+k-1])+abs(x[i+k-1]-x[i])
    a.append(min(a1,a2))
print(min(a))


Measured memory_bytes: 14384
ans=r=0

n,x=gets.split.map(&:to_i)
gets.split.map(&:to_i).sort.map{|a|
  r += a
  if x - a > 0
    ans += 1
    x -= a
  elsif x == a
    puts ans += 1
    exit
  else
    puts ans
    exit
  end
}

puts ans-1

Measured memory_bytes: 1788
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    string s,t; cin >> s >> t;
    int ans =0;
    for(int i=0; i<=s.size()-1;i++) {
        if(s[i] != t[i]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3888
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    if (N % 2 == 0)
    {
        for (int i = 0; i < N / 2; i++)
        {
            if (S[i] != S[i + N / 2])
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b)
{
    if(a>b)
        return b;
    return a;
}
ll maxx( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
signed main()
{
   ll n;
   cin>>n;
   ll a[n],b[100001]={0},c[100001]={0},d[100001]={0},e[100001]={0};
   f(i,0,n)
   {
         cin>>a[i];
         if(i%2==0)
         {
            b[a[i]]++;
            d[a[i]]++;
         }
         else
         {
            c[a[i]]++;
            e[a[i]]++;
         }
   }
   ll maxb=0,maxc=0,m1=0,m2=0;
   ll temp1=0,temp2=0;
   f(i,0,100001)
   {
        if(b[i]>maxb)
        {
            temp1=i;
            maxb=b[i];
        }
   }
   f(i,0,100001)
   {
        if(c[i]>maxc && i!=temp1)
        {
            maxc=c[i];
        }
   }
   f(i,0,100001)
   {
        if(e[i]>m1)
        {
            temp2=i;
            m1=e[i];
        }
   }
   f(i,0,100001)
   {
        if(d[i]>m2 && i!=temp2)
        {
            m2=d[i];
        }
   }
   //cout<<maxb<<maxc<<endl;
   cout<<minn(n-maxb-maxc,n-m1-m2)<<endl;
}

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

int main(){
  int t[] = {1, 0, 0};
  char a, b;
  char ch;

  while(cin >> a >> ch >> b){
    a -= 'A';
    b -= 'A';
    swap(t[a], t[b]);
  }

  if(t[0]) cout << "A" << endl;
  else if(t[1]) cout << "B" << endl;
  else if(t[2]) cout << "C" << endl;
}

Measured memory_bytes: 1136
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>

using namespace std;


int main(){
	int n;
	double x1,y1,xc,yc,dis,vx,vy,ex,ey;
	while(1){
		cin >> n;
		if(n==0)break;
		vector<double> x(n);
		vector<double> y(n);
		for(int i=0;i<n;i++){
			cin >> x[i] >> y[i];
		}
		int ans =1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)continue;
				xc = (x[i]+x[j])/2;
				yc = (y[i]+y[j])/2;
				if((xc-x[i])*(xc-x[i])+(yc-y[i])*(yc-y[i])>1.0001)continue;
				dis = sqrt(1.0-(xc-x[i])*(xc-x[i])-(yc-y[i])*(yc-y[i]));
				vx = x[i]-x[j];
				vy = y[i]-y[j];
				ex = dis * vy / sqrt(vx*vx+vy*vy);
				ey = -dis* vx / sqrt(vx*vx+vy*vy);
				x1 = xc + ex;
				y1 = yc + ey;
				int count=0;
				for(int k=0;k<n;k++){
					if(k==i||k==j)count +=1;
					else{
						if((x1-x[k])*(x1-x[k])+(y1-y[k])*(y1-y[k])<=1.0001){
							count +=1;
						}
					}
				}
				ans = max(ans,count);
				x1 = xc - ex;
				y1 = yc - ey;
				count = 0;
				for(int k=0;k<n;k++){
					if(k==i||k==j)count +=1;
					else{
						if((x1-x[k])*(x1-x[k])+(y1-y[k])*(y1-y[k])<=1.0001){
							count +=1;
						}
					}
				}
				ans = max(ans,count);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,T;
int c[100010],t[100010];

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n>>T;
    int ans=100010;
    bool can=false;
    rep(i,0,n){
        cin>>c[i]>>t[i];
        if(t[i]<=T){
            ans=min(ans,c[i]);
            can=true;
        }
    }
    if(can)cout<<ans<<endl;
    else cout<<"TLE"<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 384
import sys

n = 104729
a = [True] * n
a[0] = False
for i in range(2,n):
	if(a[i-1]):
		for j in range(i**2-1, n, i):
			a[j] = False
a = [i[0]+1 for i in enumerate(a) if i[1]]

for s in sys.stdin:
	n = int(s)
	if n == 0:
		exit()
	print(sum(a[:n]))

Measured memory_bytes: 9856
#include<iostream>
using namespace std;
 
bool overlap(int a, int b, int c, int d){
  if ( d <= a ) return false;
  if ( b <= c ) return false;
  return true;
}
 
int main(void){
  int a, b, s, f, n;
  cin >> a >> b >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> s >> f;
    if ( overlap(a, b, s, f) ){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(long long N, std::vector<long long> A){
    ll ans =0;

    ll prev=0;
    for(int i=0;i<N;i++){
        if(A[i] <prev){
            ans += (prev-A[i]);
        }else{
            prev = A[i];
        }
    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {

    ll n; cin >> n;
    ll rNum = 0;
    vector<ll> Rpos(200000,-1);
    string s; cin >> s;
    ll ans = 0;
    ll front = 0, tail = s.length()-1;

    rep(i,n){
        if(s[i] == 'R'){
            rNum ++;
        }
    }

    while(front < tail){
        if(s[front] == 'W' && s[tail] == 'R'){
            front ++;
            tail --;
            ans ++;
        }else if(s[tail] == 'W'){
            tail --;
        }else if(s[tail] == 'R' && s[front] == 'R'){
            front ++;
        }
    }


    cout << ans;


    return 0;
}


Measured memory_bytes: 5164
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
 
int N;
string S;
long long R;
long long G;
long long B;
long long sum;
long long ans;
 
 
 
int main() {
    cin >> N >> S;
    for (int i = 0;i<N;i++){
        if (S[i] == 'R'){
            R += 1;
        } else if (S[i] == 'G'){
            G += 1;
        } else {
            B += 1;
        }
    }
    for (int i = 0;i<N-2;i++){
        for (int j = 1;j <= (N-i -1)/2;j++){
            if (S[i] != S[i+j] && S[i+2*j] != S[i+j] && S[i] != S[i+2*j]){
                sum += 1;
            }
        }
    }
    ans = R * G * B - sum;
    cout << ans << endl;
}


Measured memory_bytes: 3624
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize_read();

    let mut dp = vec![std::usize::MAX; n + 1];
    dp[0] = 0;
    for i in 0..n {
        dp[i + 1] = cmp::min(dp[i] + 1, dp[i + 1]);

        let mut six = 1;
        while i + six * 6 <= n {
            dp[i + six * 6] = cmp::min(dp[i + six * 6], dp[i] + 1);
            six *= 6;
        }

        let mut nine = 1;
        while i + nine * 9 <= n {
            dp[i + nine * 9] = cmp::min(dp[i + nine * 9], dp[i] + 1);
            nine *= 9;
        }
    }
    println!("{}", dp[n]);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
import java.util.*;
import java.lang.*;

public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] inp = s.split(" ");
    int A = Integer.parseInt(inp[0]);
    int B = Integer.parseInt(inp[1]);
    int C = Integer.parseInt(inp[2]);
    int D = Integer.parseInt(inp[3]);
    int start = Math.max(A, C);
    int end = Math.min(B, D);
    int out = end - start;
    if (out < 0) out = 0;
    System.out.println(out);
  }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};
int cnt[1000000];

int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n;
        cin>>n;
        int a[n];
        fori(i,n) cin>>a[i], cnt[a[i]]++;
        int ans = 0;
        fori(i,n) {
            if(cnt[a[i]] == 1) {
                cnt[a[i]]--;
                bool f = 1;
                for(int j = 1;j*j<=a[i];j++) {
                    if((a[i]%j == 0) &&(cnt[j] || cnt[a[i]/j])) {
                        f = 0;
                        break;
                    }
                }
                cnt[a[i]]++;
                ans += f;
            }
        }
        cout<<ans;

    }
    
    return 0;
}

Measured memory_bytes: 12860
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
/*----------------------------------------------------------------------*/

const int N = 2e5+5;
ll dp[N];
ll hh[N],aa[N];

ll tree[4*N];

/**
 * Increment elements within range [i, j] with value value
 */
void update_tree(int node, int a, int b, int i, int j, ll value) {
    
	if(a > b || a > j || b < i) // Current segment is not within range [i, j]
		return;
    
  	if(a == b) { // Leaf node
    		tree[node] = max(tree[node], value);
    		return;
	}

	update_tree(node*2, a, (a+b)/2, i, j, value); // Updating left child
	update_tree(1+node*2, 1+(a+b)/2, b, i, j, value); // Updating right child

	tree[node] = max(tree[node*2], tree[node*2+1]); // Updating root with max value
}

/**
 * Query tree to get max element value within range [i, j]
 */
ll query_tree(int node, int a, int b, int i, int j) {
	
	if(a > b || a > j || b < i) return -INF; // Out of range

	if(a >= i && b <= j) // Current segment is totally within range [i, j]
		return tree[node];

	ll q1 = query_tree(node*2, a, (a+b)/2, i, j); // Query left child
	ll q2 = query_tree(1+node*2, 1+(a+b)/2, b, i, j); // Query right child

	ll res = max(q1, q2); // Return final result
	
	return res;
}


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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,ht,a,idx;
    cin>>n;
    F(i, 0, n) cin>>hh[i];
    F(i, 0, n) cin>>aa[i];
    memset(dp, 0, sizeof(dp)); memset(tree, 0, sizeof(tree));
    F(i, 0, n) {
    	ll mxsofar = max(0LL, query_tree(1, 0, N, 0, hh[i]-1));
    	dp[hh[i]] = mxsofar + aa[i];
    	update_tree(1, 0, N, hh[i], hh[i], dp[hh[i]]);
    }
    cout<<*max_element(dp, dp+N);
    return 0;
}/*

*/

Measured memory_bytes: 11264
n,x = map(int,input().split())

a=[0]*n
p=[0]*n

a[0]=1
p[0]=1

for i in range(1,n):
  a[i]=3+2*a[i-1]
  p[i]=1+2*p[i-1]
  
def f(n,x):
  if n ==0:
    return 0 if x <= 0 else 1
  elif x <= 1+a[n-1]:
    return f(n-1,x-1)
  else:
    return p[n-1]+1+f(n-1,x-a[n-1]-2)

print(f(n,x))



Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	a = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int r,g,b,n,i,j,ans=0;
	cin >> r >> g >> b >> n;
	for(i=0; i<=3000; ++i){
		for(j=0; j<=3000; ++j){
			if(i*r+j*g>n){
				continue;
			}else if((n-i*r-j*g)%b){
				continue;
			}
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

import javax.swing.text.AbstractDocument.BranchElement;

import com.sun.org.apache.xpath.internal.SourceTree;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
int a[N];
int b[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i];
   }
   sort(a+1,a+1+n);
    int mid=n/2;
    for(int i=1;i<=n;i++){
        if(b[i]<=a[mid])
        printf("%d\n",a[mid+1]);
        else
        printf("%d\n",a[mid]);
    }
}


Measured memory_bytes: 7040
#include <cstdio>

int main() {
    int a, b;
    scanf("%d%d", &a, &b);

    if(a < b) {
        printf("a < b\n");
    }
    else if(a > b) {
        printf("a > b\n");
    }
    else if(a == b) {
        printf("a == b\n");
    }
}


Measured memory_bytes: 2592
n = int(input())
d = list(map(int,input().split()))

if d[0] != 0:
    print("0")
    exit()

count = 1
dmax = max(d)
num_array = [0] * (dmax+1)

for i in range(len(d)):
    num_array[d[i]] += 1

if num_array[0] != 1:
    print("0")
    exit()
if 0 in num_array:
    print("0")
    exit()
for i in range(1, dmax+1):
    count *= num_array[i-1] ** num_array[i]
    count %= 998244353
print(count)


Measured memory_bytes: 14396
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if abs(x-a) < abs(x-b) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}


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

int main(){
    string s;
    cin >> s;
    if(s[0]== s[1] && s[1] == s[2])
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

template <long long mod> class modint
{
private:
    long long x;
public:
    modint(long long x = 0) : x(x % mod) {}
    modint& operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint& operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const {return modint(*this) += rhs;}
    modint operator-(const modint rhs) const {return modint(*this) -= rhs;}
    modint operator*(const modint rhs) const {return modint(*this) *= rhs;}
    modint operator/(const modint rhs) const {return modint(*this) /= rhs;}

    modint pow(long long n) const { // n乗を求める
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { // 逆元を求める
        return pow(mod - 2);
    }

    friend ostream& operator<<(ostream& os, const modint<mod>& m) {
        os << m.x;
        return os;
    }

    friend istream& operator>>(istream& is, modint<mod>& m) {
        long long in;
        is >> in;
        m = modint<mod>(in);
        return is;
    }
};
using mint = modint<1000000007>;

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

int main()
{
    int n; cin >> n;
    map<int, int> mp;
    for (int i = 2; i <= n; i++) {
        int num = i;
        for (int j = 2; j * j <= num; j++) {
            while (num % j == 0) {
                mp[j]++; num /= j;
            }
        }
        if (num != 1) mp[num]++;
    }
    mint ans(1);
    for (auto& e: mp) {
        ans *= mint(e.second + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	for(int i=b-(a-1);i<=b+(a-1);i++){
		cout<<i<<' ';
	}cout<<endl;return 0;
}/*『你强归你强，我永不示弱』*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  while(int n = getInt()){
    vector<int> a(n);
    vector<int> b(n);
    vector<int> m(n);

    map<int,int> w;

    REP(i,n){
      m[i] = getInt();
      a[i] = getInt();
      b[i] = getInt();

      w[a[i]] = 0;
      w[b[i]] = 0;
    }

    REP(i,n){
      FOR(it, w){
	int t = it->f;
	if(a[i] <= t && t < b[i])
	  it->s += m[i];
      }
    }

    int maxElem = 0;
    FOR(it, w) maxElem = max(maxElem, it->s);

    puts(maxElem > 150 ? "NG" : "OK");
  }
  return 0;
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;
use std::collections::BinaryHeap;

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

fn digits(mut v: usize) -> usize {
    let mut ret = 0;
    while v > 0 {
        ret += v % 10;
        v /= 10;
    }
    ret
}
fn main() {
    let n: usize = read();
    let mut que = BinaryHeap::<(i32, usize)>::new();
    let mut visit = vec![false; n];
    let mut dists = vec![i32::max_value(); n];
    que.push((0, 0));
    let mut ans = digits(n);
    while let Some((cost, v)) = que.pop() {
        let cost = -cost;
        if visit[v] {
            continue;
        }
        visit[v] = true;
        for i in 0..10 {
            let nv = (v + i * n) / 10;
            let ncost = cost as usize + (v + i * n) % 10;
            let ncost = ncost as i32;
            if visit[nv] || dists[nv] <= ncost {
                continue;
            }
            dists[nv] = ncost;
            que.push((-ncost, nv));
            ans = std::cmp::min(ans, digits(nv) + ncost as usize);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 19704
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool cmp(pair<int,int> l,pair<int,int> r)
{
    if(l.first<r.first)
        return 1;
    if(l.first>r.first)
        return 0;
    if(l.second>r.second)
        return 1;
    return 0;
}

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    vector<pair<int,int> >v;
    for(int i=0; i<n; i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(all(v),cmp);
    vector<int>cur;
    for(int i=0; i<n-1; i++)
        cur.push_back(v[i].second);
    sort(all(cur));

    int it=n-2,att=v[n-1].first,rev_sum=0,cnt=0;
    int need=m/att;
    if(m%att)
        need++;
    while(it>=0)
    {
        cnt++;
        rev_sum+=cur[it--];
        int temp_m=m-rev_sum;
        temp_m=max(temp_m,0);
        int t_need=temp_m/att;
        if(temp_m%att)
            t_need++;
        need=min(need,t_need+cnt);

        cnt++;
        rev_sum+=v[n-1].second;
        temp_m=m-rev_sum;
        temp_m=max(temp_m,0);
        t_need=temp_m/att;
        if(temp_m%att)
            t_need++;
        need=min(need,t_need+cnt);

        cnt--;
        rev_sum-=v[n-1].second;



    }
    int t=m-v[n-1].second;
    t=max(t,0);
    int t2=t/att;
    if(t%att)
        t2++;
    need=min(need,t2+1);
    cout<<need<<endl;

    return 0;
}


Measured memory_bytes: 4752
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j,sum = 0,minj;
	int a[100];
	cin >> n;
	for (i = 0 ; i < n ; i++) cin >> a[i];
	
	for (i = 0 ; i < n ; i++)
	{
		minj = i;
		for (j = i ; j < n ; j++)
        {
		    if (a[j] < a[minj]) 
		    {
		    	minj = j;	
			}
	    }
	    if (minj != i) 
		{
		    sum+=1;
		}
		swap(a[i] , a[minj]);
	}
	
	for (i = 0 ; i < n ; i++)
	{
		if (i != 0 )
		{
		    cout << " ";
	    }
		cout << a[i];
	}
	cout << "\n";
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3100
import sys
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n-i+1):
        k=n-i-j
        if 10000*i+5000*j+1000*k == y:
            print(i,j,k)
            sys.exit()
print(-1,-1,-1)


Measured memory_bytes: 2940
a = input()
b = input()
if a == "1":
    if b == "2":
        print(3)
    elif b == "3":
        print(2)
if a == "2":
    if b == "1":
        print(3)
    elif b == "3":
        print(1)
if a == "3":
    if b == "1":
        print(2)
    elif b == "2":
        print(1)

Measured memory_bytes: 38256
#include<cstdio>
#include<cctype>
#include<algorithm>
const int maxn=200010,inf=0x7fffffff;
int n;
int a[maxn];
bool v[maxn];
int ans;
int In() {
    register char c;
    for(;c=getchar(),c!='-'&&!isdigit(c););
    register bool f=c=='-';
    register int s=f?0:c-'0';
    for(;c=getchar(),isdigit(c);)s=s*10+c-'0';
    return f?-s:s;
}
int main() {
	n=In();
	for(register int i=1;i<=n;++i)a[i]=In();
	std::sort(a+1,a+n+1);
	for(register int i=30;i;--i) {
		register int l=1,r=n;
		for(register int p=1<<i;l<r;--r) {
			for(;l<r&&v[r];--r);
			for(;l<r&&a[l]+a[r]<p;++l);
			for(;l<r&&v[l];++l);
			if(l>=r) break;
			if(a[l]+a[r]==p) v[l]=v[r]=1,++ans,++l;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  long N = readln.chomp.to!long;
  bool[long] A;

  foreach (_; 0..N) {
    long a = readln.chomp.to!long;

    if (a in A) {
      A[a] = !A[a];
    } else {
      A[a] = true;
    }
  }

  long ans;

  foreach (k, v; A) {
    if (v) { ans++; }
  }

  writeln(ans);
}


Measured memory_bytes: 8316
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import fractions


def main():
    n = int(input())
    t = [None] * n

    for i in range(n):
        t[i] = int(input())

    ans = t[0]
    for i in range(1, n):
        ans = ans * t[i] // fractions.gcd(ans, t[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
wait = defaultdict(int)
ans = 0

for Ai in A:
    if wait[Ai]>=1:
        ans += 1
        wait[Ai] -= 1
    else:
        t = 0
    
        while 2**t<=Ai:
            t += 1
    
        wait[2**t-Ai] += 1

print(ans)

Measured memory_bytes: 155712
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	int H, A;

	cin >> H >> A;

	int ans = 0;

	while (H > 0) {
		ans += 1;
		H -= A;
	}

	cout << ans;
}

Measured memory_bytes: 256
using System;

namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[,] isHaved = new bool[4,13];
            int noOfCardsInHand = int.Parse(Console.ReadLine());
            for(int i=0; i<noOfCardsInHand;i++)
            {
                var input = Console.ReadLine().Split(' ');
                int suffix;
                suffix = int.Parse(input[1]);
                switch(input[0])
                {
                    case "S":
                        isHaved[0, suffix-1] = true;
                        break;
                    case "H":
                        isHaved[1, suffix-1] = true;
                        break;
                    case "C":
                        isHaved[2, suffix-1] = true;
                        break;
                    case "D":
                        isHaved[3, suffix-1] = true;
                        break;
                    default: break;
                }
            }

            for(int i=0; i<4; i++)
            {
                for(int j=0;j<13;j++)
                {
                    if(isHaved[i, j]==false)
                    {
                        if (i == 0) Console.WriteLine("S {0}",j+1);
                        if (i == 1) Console.WriteLine("H {0}",j+1);
                        if (i == 2) Console.WriteLine("C {0}",j+1);
                        if (i == 3) Console.WriteLine("D {0}",j+1);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 5744
#include<iostream>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a>=1&&a<=100)&&(b>=1&&b<=100)&&(c>=1&&c<=100)){
        if((a+b==c)||(b+c==a)||(a+c==b)){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
double x1,x2,y1,y2;
x1 =sc.nextDouble();
y1 =sc.nextDouble();
x2 =sc.nextDouble();
y2 =sc.nextDouble();
if(x1==x2) System.out.println(y2-y1);
else if(y1==y2) System.out.println(x2-x1);
else
System.out.println(Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2)));
}
}

Measured memory_bytes: 18336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int mod = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main() {
    int a, p; cin >> a >> p;
    p += a * 3;
    cout << p / 2 << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(string s){
	s.insert(4, " ");
	cout << s << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	solve(s);
	return 0;
}


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

int main(){
    ll n, k;
    cin >> n >> k;
    ll a;
    a = n / k;
    n -= k*a;
    if (n > k/2) n = k-n;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256