akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 2e9+7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mxN=1010;
int a[mxN];
int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m; cin>>n>>m; int sum=0;
    for(int i=1;i<=n;i++) {
        cin>>a[i]; sum+=a[i];
    }
    sort(a+1,a+1+n);
    int temp=ceil(1.0*sum/4.0/m);
    int cnt=0;
    for(int i=1;i<=n;i++) {
        //cout<<a[i]<<" ";
        if(a[i]>=temp) cnt++;
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
def solve(i, m, n, num)
	return true if m == 0
	return false if i >= n
	return solve(i + 1, m, n, num) || solve(i + 1, m - num[i], n, num)
end


n = gets.to_i
num = gets.split.map(&:to_i)
m = gets.to_i
qu = gets.split.map(&:to_i)

	m.times do |j|
	 if solve 0, qu[j], n, num
	 	puts "yes"
	 else
	 	puts "no"
	 end
	end

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

using namespace std; 	
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5+50;
const int oo = 1e9;
const int mod = 1e5;

string a[N];
int main(){
	int n;
	cin>>n;
	cout << '0' << endl;
	cout.flush();
	string p;
	cin>>p;
	a[0] = p;
	for(int i=1;i<n;i++){
		if(a[i-1] == "Male"){
			a[i] = "Female";
		}else{
			a[i] = "Male";
		}
	}
	int md,lo=0,hi=n;
	while(lo<=hi){
		md = (lo+hi)>>1;
		cout << md << endl;
		cout.flush();
		cin>>p;
		if(p=="Vacant"){
			return 0;
		}
		if(p==a[md]){
			lo = md+1;
		}else{
			hi = md-1;
		}
	}
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long N, A, B; cin >> N >> A >> B;
	assert(A != B);
	if (A > B) swap(A,B);
	assert(A < B);
	if (A % 2 == B % 2) {
		cout << (B-A) / 2 << '\n';
	} else {
		cout << min((N-B) + 1 + (N-A), (A-1) + 1 + (B-1)) / 2<< '\n';
	}
 
	return 0;
}


Measured memory_bytes: 256
# ALDS1_5_B Merge Sort
import sys
count = 0

def merge(A, left, mid, right):
    global count
    l = A[left: mid]
    r = A[mid: right]

    l.append(float('inf'))
    r.append(float('inf'))

    i = 0
    j = 0

    for k in range(left, right, 1):
        count += 1
        if l[i] <= r[j]:
            A[k] = l[i]
            i += 1
        else:
            A[k] = r[j]
            j += 1


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


n = int(input())
S = [int(i) for i in sys.stdin.readline().strip().split()]

merge_sort(S, 0, n)
print(' '.join(map(str, S)))
print(count)


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

int main(void){
    int N,K; cin >> N >> K;
    int ans=0;

    for(int i=0; i<N; i++){
        int a; cin >> a;
        ans+=2*min(a,K-a);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
// #define map unordered_map
// #define set unordered_set

using namespace std;

const ll MOD = 1000000007;

// set<ll> dp[82][82];

ll table1[82][82];
ll table2[82][82];

const int MAX = 160 * 80;

bool dp[82][82][MAX + 1];

int main() {
  ll H, W;
  scanf("%lld %lld", &H, &W);

  for (ll i = 1; i <= H; i++) {
    for (ll j = 1; j <= W; j++) {
      ll v;
      scanf("%lld", &v);
      table1[j][i] = v;
    }
  }
  for (ll i = 1; i <= H; i++) {
    for (ll j = 1; j <= W; j++) {
      ll v;
      scanf("%lld", &v);
      table2[j][i] = v;
    }
  }

  dp[1][1][0] = 1;
  for (ll x = 1; x <= W; x++) {
    // cout << "x:" << x << endl;
    for (ll y = 1; y <= H; y++) {
      ll df = table1[x][y] - table2[x][y];

      for (ll i = 0; i <= MAX; i++) {
        if (dp[x][y][i]) {
          ll value1 = abs(i + df);
          ll value2 = abs(i - df);
          dp[x + 1][y][value1] = 1;
          dp[x + 1][y][value2] = 1;
          dp[x][y + 1][value1] = 1;
          dp[x][y + 1][value2] = 1;
        }
      }
    }
  }

  ll lastdiff = table1[W][H] - table2[W][H];

  ll ans = 9999999LL;
  for (ll i = 0; i <= MAX; i++) {
    if (dp[W][H][i]) {
      ans = min(ans, abs(i + lastdiff));
      ans = min(ans, abs(i - lastdiff));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 82944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100001],dp[100001][2];
int n;


int main(){

    string s;
    cin>>s;
    int c=0,ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='R'){
            c++;
        }
        else{
            c=0;
        }
        ans=max(c,ans);
    }
    cout<<ans;




return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int main(void){
    char buf[200];
    int n=0,max=0,i=0;

    scanf("%*d%*c");
    my_gets(buf,200,stdin);
    do{
        n += (buf[i]=='I')?(1):(-1);
        if(n>max) max=n;
    }while(buf[++i]);
    printf("%d\n",max);
}

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


int main() {

    string s1, s2;
    int n;

    cin >> n;


    cin >> s1 >> s2;

    for(int i = 0; i < n; ++i)
        cout << s1[i] << s2[i];

    cout << endl;

    return 0;


}

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

int main () {
  int a,b,k;
  cin >> a >> b;
  if((a + b)%2 != 0 ) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  else k = (a + b) / 2;
  
  cout << k << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(n) for n in input().split(' ')]
 
ans = 0
for i in range(60):
    x = 0
    for A_i in A:
        if A_i>>i&1:
            x += 1
    ans += x*(N-x)*2**i
ans = ans % (10**9+7)
print(ans)


Measured memory_bytes: 139120
#include <bits/stdc++.h>
using namespace std;
const int maxn = 202000;
int pref[maxn];
vector<int> e[maxn];
int sum(int l, int r){
	return pref[r] - pref[l - 1];
}
int mx[maxn<<2], lazy[maxn<<2];
void push(int id, int l, int r){
	if(lazy[id]){
		mx[id] += lazy[id];
		if(l != r){
			lazy[id<<1] += lazy[id];
			lazy[id<<1|1] += lazy[id];
		}
		lazy[id] = 0;
	}
}
void add(int id, int l, int r, int x, int y, int v){
	push(id, l, r);
	if(l > y || r < x) return;
	if(x <= l && r <= y){
		lazy[id] += v;
		push(id, l, r);
		return;
	}
	int mid = (l + r)>>1;
	add(id<<1, l, mid, x, y, v);
	add(id<<1|1, mid + 1, r, x, y, v);
	mx[id] = max(mx[id<<1], mx[id<<1|1]);
}
void add_all(int l, int r, int x){
	add(1, 0, maxn, l, r, x);
}
void upd(int id, int l, int r, int p, int v){
	push(id, l, r);
	if(l > p || r < p) return;
	if(p <= l && r <= p){
		mx[id] = max(mx[id], v);
		return;
	}
	int mid = (l+r)>>1;
	upd(id<<1, l, mid, p, v);
	upd(id<<1|1, mid + 1, r, p, v);
	mx[id] = max(mx[id<<1], mx[id<<1|1]);
}
void upd_max(int p, int x){
	upd(1, 0, maxn, p, x);
}
int get(int id, int l, int r, int x, int y){
	push(id, l, r);
	if(l > y || r < x) return -(1<<30);
	if(x <= l && r <= y) return mx[id];
	int mid = (l + r)>>1;
	return max(get(id<<1, l, mid, x, y), get(id<<1|1, mid + 1, r, x, y));
}
int get_max(int l, int r){
	return get(1, 0, maxn, l, r);
}
int main(){
	int n; cin >> n;
	for(int i = 0, x; i < n; i++){
		cin >> x;
		pref[i + 1] = pref[i] + x;
	}
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		int l, r; cin >> l >> r;
		e[l].push_back(r);
	}
	for(int i = 1; i <= n; i++){
		add_all(i, i, -pref[i]);
	}
	for(int i = 1; i <= n; i++){
		for(int to : e[i]){
			int best = get_max(i, to);
			upd_max(to, best);
			int opt2 = get_max(0, i - 1) - pref[i - 1];
			upd_max(to, opt2);
		}
		if(sum(i, i) == 0){
			add_all(0, i - 1, 1);
		}
		add_all(i, i, pref[i]);
	}
	cout << n - get_max(0, n) << endl;
	return 0;
}


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

int main(){
  while(1){
    ll m,c,n;
    cin>>m>>c>>n;
    if(!m&&!c&&!n)return 0;

    vector<ll> book[101],D[21];
    
    for(int i=0;i<n;i++){
      int k;
      cin>>k;
      book[i].resize(k);
      for(int j=0;j<k;j++) cin>>book[i][j],D[m].push_back(book[i][j]);
    }

    queue<int> Q;
    for(int i=0;i<100;i++)
      for(int j=0;j<n;j++)
	if((int)book[j].size()>i)Q.push(book[j][i]);
  
    ll d[11],ans=0;
    for(int i=0;i<m;i++)d[i]=c;  
    d[m]=1e9;
    
    while(!Q.empty()){
      ll id=Q.front();Q.pop();
      ll cost=0;

      for(int i=0;i<=m&&!cost;i++)
	for(int j=0;j<(int)D[i].size()&&!cost;j++)
	  if(id==D[i][j])cost=i+1,D[i].erase(D[i].begin()+j);
      
      ans+=cost;
      cost=0;
      if(D[0].size()<d[0]){
	D[0].push_back(id),ans+=1;
	continue;
      }

      int pos=0;
      for(int i=0;i<=m&&!cost;i++)
	if(D[i].size()<d[i])D[i].push_back(id),cost=(i+1)*2+1,pos=i;
      
      ans+=cost;
      cost=0;
      for(int i=0;i<=m&&!cost;i++)
	if(D[i].size()<d[i]){
	  D[i].push_back(D[0][0]);
	  D[0].erase(D[0].begin());
	  cost=i+2;
	}
      ans+=cost;      
      cost=0;
      for(int i=0;i<D[pos].size();i++) if(D[pos][i]==id)D[pos].erase(D[pos].begin()+i);
      D[0].push_back(id);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e5+10;
int dis[maxn],vis[maxn],par[maxn];
int32_t main(){
	IOS
	for(int i=0;i<maxn;i++){
		dis[i]=1e18;
		vis[i]=0;
	}
	vector<int>dx;
	dx.push_back(1);
	for(int i=1;i*6<maxn;i*=6){
		dx.push_back(i*6);
	}
	for(int i=1;i*9<maxn;i*=9){
		dx.push_back(i*9);
	}
	dis[0]=0;
	priority_queue< pair<int,int> , vector<pair<int,int>> , greater<pair<int,int>> >pq;
	pq.push({dis[0],0});
	while( pq.size() ){
		int u = pq.top().second;pq.pop();
		if(vis[u])continue;
		vis[u]=1;
		for(size_t i=0;i<dx.size();i++){
			if( u + dx[i] < maxn && dis[u+dx[i]] > dis[u] + 1){
				par[u+dx[i]]=u;
				dis[u+dx[i]]=dis[u]+1;
				pq.push({dis[u+dx[i]],u+dx[i]});
			}
			/*if( u - dx[i] >= 0   && dis[u-dx[i]] > dis[u] + 1){
				par[u-dx[i]]=u;
				dis[u-dx[i]]=dis[u]+1;
				pq.push({dis[u-dx[i]],u-dx[i]});
			}*/
		}
	}
	int n;cin>>n;
	cout<<dis[n];

	
 }
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    int n; cin >> n;
    vector<int> t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
    Rep(i, 1, n + 1) cin >> t[i] >> x[i] >> y[i];

    bool f = true;
    rep(i, n)
    {
        int dt = t[i + 1] - t[i];
        int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if (dt < dist) f = false;
        if (dt % 2 != dist % 2) f = false;
    }

    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int read()
{
	int i=0,f=1;char c=getchar();
	while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {i=i*10+c-'0';c=getchar();}
	return i*f;
}
struct cx
{
	int a,b;
}e[10];
int k[10];
int ans=0,pd=0;
bool cmp(cx a,cx b){return a.b>b.b;}
int main()
{
	for(int i=1;i<=5;i++)
		e[i].a=read();
	for(int i=1;i<=5;i++)
		e[i].b=e[i].a%10;
	sort(e+1,e+6,cmp);
	for(int i=5;i>=1;i--)
	{
		if(e[i].b==0) {k[i]=e[i].a;continue;	}
		if(pd==0){pd=1;k[i]=e[i].a;}
		else	  k[i]=(e[i].a/10+1)*10;
	}
	for(int i=1;i<=5;i++)
		ans+=k[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MAX_W (10)
bool enable[MAX_W][MAX_W];	// 通ったか
bool check[MAX_W][MAX_W];	// 通ったか
int H, W;

bool check_range(P p) {
    if ( p.first < W && p.second < H ) {
	if ( enable[p.first][p.second] ) {
	    return true;
	}
    }

    return false;
}

int main()
{

    scanf("%d %d", &H, &W);
    for ( int i = 0; i < H; i++ ) {
	for ( int j = 0; j < W; j++ ) {
	    char c;
	    scanf(" %c", &c);
	    enable[j][i] = (c== '#') ? true : false;
	}
    }

    if ( !enable[0][0] ) {
	printf("Impossible\n");
	return 0;
    }
    queue<P> q;
    q.push(make_pair(0, 0));
    check[0][0] = true;
    bool ans = false;
    while ( !q.empty() ) {
	P cur = q.front();
	q.pop();
	P r = make_pair(cur.first + 1, cur.second);
	P b = make_pair(cur.first, cur.second + 1);

	if ( (cur.first == (W-1)) && (cur.second == (H-1)) ) {
	    ans = true;
	    check[W-1][H-1] = true;
	    break;
	}

	// 2通りあり
	if ( check_range(r) && check_range(b) ) {
	    break;
	}
	else if ( check_range(r) ) {
	    q.push(r);
	    check[r.first][r.second] = true;
	}
	else if ( check_range(b) ) {
	    q.push(b);
	    check[b.first][b.second] = true;
	}
    }

    for ( int i = 0; i < H; i++ ) {
	for ( int j = 0; j < W; j++ ) {
	    if ( enable[j][i] ) {
		if (!check[j][i]) {
		    ans = false;
		    break;
		}
	    }
	}
    }

    if ( ans ) {
	printf("Possible\n");
    }
    else {
	printf("Impossible\n");
    }

    return 0;
}


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

using namespace std;

void __start__() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MY
    freopen("/home/ainur/CLionProjects/wow/input.txt", "r", stdin);
    freopen("/home/ainur/CLionProjects/wow/output.txt", "w", stdout);
#else
#define endl '\n'
    //freopen("search.in", "r", stdin);
    //freopen("search.out", "w", stdout);
#endif
}

#define sz(x) (int)x.size()
#define yes cout<<"Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ft first
#define sd second
#define read(a) for(auto &qwqw:a)cin >> qwqw;
#define print(a) for(auto qwqw:a)cout<<qwqw<<' ';
#define print_plus(a) for(auto qwqw:a)cout<<qwqw+1<<' ';
//#define FOR(i, b, n) for(int i=b;i<n;i++) #define FOR(i, n) FOR(i, 0, n) #define FOR(n) FOR(i, 0, n)
mt19937_64 rnd(time(0));
#define int long long
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vb = vector<bool>;
using pii = pair<int, int>;
using vd = vector<long double>;


int log2(int q) {
    int c = 0;
    while (q) {
        q >>= 1;
        c++;
    }
    return c;
}

void test_case() {
    int n;
    cin >> n;
    cout << (1000-n%1000)%1000;
}

signed main() {
    __start__();
    int Q = 1;
    //cin >> Q;
    while (Q--) {
        test_case();
    }
}





Measured memory_bytes: 3664
n = gets.chomp.to_i
dict = {}
m = 1
n.times do
  k = gets.chomp
  if dict.has_key?(k)
    dict[k] += 1
    m = dict[k] if m < dict[k]
  else
    dict.merge!({k => 1})
  end
end
puts(dict.select{|key, val| val==m}.keys.sort)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int32_t main()
{
     int n;
     cin>>n;
     int a,b,c1=0,c2=0,c3=0;
     cin>>a>>b;
     for(int i=1;i<=n;i++)
     {
          int x;
          cin>>x;
          if(x<=a)
               c1++;
          else if(x>b)
               c3++;
          else
               c2++;
     }
     int ans=min(c1,c2);
     cout<<min(ans,c3);
     return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n=in(),p,q[200001]={},i,a=1,m=0;
    rep(i,n){
        p=in();
        q[p]=i+1;
    }
    rep(i,n){
        if(q[i+1]<q[i+2])a++;
        else a=1;
        m=max(m,a);
    }
    print(n-m);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S; cin >> S;
    sort(S.begin(), S.end());
    for (int i = 0; i < S.length() - 1; ++i) {
        if (S[i] == S[i + 1]) {
            printf("%s\n", "no");
            return 0;
        }
    }
    printf("%s\n", "yes");
    return 0;
}


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

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

  vector<int> a(n);

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

  }

  sort(a.begin(), a.end());

  int ans = 1000000000;

  for(int i = 0; i < n; i++){
    ans = min(ans, __gcd(a[0], a[i]));
  }

  cout << ans << endl;

  return 0;

}


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

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

    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            if(i*4+j*7==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

    cout<<"No"<<endl;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 1e9 + 7;
const ll MAX_B = 62;
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  vector<vector<ll>> bsum(n+1,vector<ll>(MAX_B,0));
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=n-1;i>=0;i--){
    bsum[i] = bsum[i+1];
    for(ll j=0;j<MAX_B;j++){
      if(a[i]&(1ll<<j)){
        bsum[i][j]++;
        bsum[i][j] %= MOD;
      }
    }
  }
  for(int i=0;i<n;i++){
    ll ad=1;
    for(ll j=0;j<MAX_B;j++){
      if(a[i]&(1ll<<j)){
        ans += ad * ((n-i-1)-bsum[i+1][j]);
      }else{
        ans += ad * (bsum[i+1][j]);
      }
      ans %= MOD;
      ad *= 2;
      ad %= MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 159616
def mod_pow(a, x, p):
    res = 1
    while x > 0:
        if x % 2 != 0:
            res = (res * a) % p
        a = (a * a) % p
        x //= 2
    return res


def mod_inv(a, p):
    return mod_pow(a, p-2, p)


def mod_binomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % p

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    return (numerator * mod_inv(denominator, p)) % p


X, Y = map(int, input().split())

a = (2*Y-X) / 3
b = (2*X-Y) / 3

if a >= 0 and b >= 0 and a == int(a) and b == int(b):
    a = int(a)
    b = int(b)

    print(mod_binomial(a+b, a, 10**9+7))
else:
    print(0)


Measured memory_bytes: 3064
/*input
1
*/

#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 x;
  cin >> x;
  for (ll a = -1000; a <= 1000; ++a) {
    for (ll b = -1000; b <= 1000; ++b) {
      ll a5 = a*a*a*a*a;
      ll b5 = b*b*b*b*b;
      if (a5-b5 == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	string N;
	cin >> N;
	
	bool allNine=true;
	for(int i=1;i<N.size();i++)
		if(N[i]!='9')
			allNine=false;
	
	int ans=0;
	int tmp=0;
	for(int i=0;i<N.size();i++)
		tmp+=(N[i]-'0');
	ans=tmp;
	
	if(allNine)
		ans=max(ans,N[0]-'0'+(int)(N.size()-1)*9);
	else
		ans=max(ans,N[0]-'0'-1+(int)(N.size()-1)*9);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int X = cin.nextInt();

        if (A <= X && A + B >= X)
        {
            Console.WriteLine("YES");
            return;
        }
        Console.WriteLine("NO");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
import java.io.*;
import java.util.StringTokenizer;


public class Main {

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();

        long a  = fs.nextLong();
        long b = fs.nextLong();
        long n = fs.nextLong();

        long x = Math.min(b - 1, n);

        System.out.println(Math.floorDiv(a * x, b) + a * Math.floorDiv(x, b));
    }
}


Measured memory_bytes: 32736
import numpy as np
import sys
n,m,x = map(int,input().split())
input_list = [np.array(list(map(int,input().split()))) for _ in range(n)]
temp_fee = sys.maxsize
for i in range(2**n):
    list2 = [np.array([0]*(m+1))]
    for j in range(n):
        if (i >> j) &1 == 1:
            list2.append(input_list[j])
    list3 = sum(list2)
    if min(list3[1:])>=x and list3[0]<temp_fee:
        temp_fee = list3[0]
if temp_fee != sys.maxsize:
    print(temp_fee)
else:
    print(-1)

Measured memory_bytes: 27208
k,n = list(map(int, input().split()))
a = list(map(int, input().split()))
# 1～nまでの家間の距離
distance=[a[i]-a[i-1] for i in range(1,n)]
# 末尾～先頭の距離を追加
distance.append(k-sum(distance))

# 円周から最大距離を除いたものが最短距離
print(k-max(distance))

Measured memory_bytes: 25836
#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() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> r_cnt(n, 0);
  vector<int> g_cnt(n, 0);
  vector<int> b_cnt(n, 0);
  if (s[n-1] == 'R') r_cnt[n-1] = 1;
  if (s[n-1] == 'G') g_cnt[n-1] = 1;
  if (s[n-1] == 'B') b_cnt[n-1] = 1;

  for (int i=n-2; i>=0; i--) {
    r_cnt[i] = r_cnt[i+1];
    g_cnt[i] = g_cnt[i+1];
    b_cnt[i] = b_cnt[i+1];
    if (s[i] == 'R') r_cnt[i]++;
    if (s[i] == 'G') g_cnt[i]++;
    if (s[i] == 'B') b_cnt[i]++;
  }

  ll cnt = 0;
  for (int i=0; i<n-2; i++) {
    for (int j=i+1; j<n-1; j++) {
      char c1, c2, c;
      c1 = s[i];
      c2 = s[j];
      string temp = s.substr(j+1);
      if ((c1=='R'&&c2=='G')||(c1=='G'&&c2=='R')) {
        c = 'B';
        cnt += b_cnt[j+1];
      } else if ((c1=='R'&&c2=='B')||(c1=='B'&&c2=='R')) {
        c = 'G';
        cnt += g_cnt[j+1];
      } else if ((c1=='G'&&c2=='B')||(c1=='B'&&c2=='G')) {
        c = 'R';
        cnt += r_cnt[j+1];
      } else {
        continue;
      }
      if (temp.size() >= j-i && temp[j-i-1] == c) cnt--;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; ll T; cin >> N >> T;
    vel A(N); rep(i,N) cin >> A[i];

    ll mi = INF; ll diff = 0; int cnt = 1;
    rep(i,N) {
        if(mi > A[i])  mi = A[i];
        else {
            if(diff == A[i] - mi) cnt++;
            if(diff < A[i] - mi) { cnt = 1; diff = A[i] - mi; }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

//https://atcoder.jp/contests/agc039/tasks/agc039_a
int main(void)
{
    string S;
    cin >> S;
    ll K;
    cin >> K;
    
    ll n = S.length();

    string tmp = S;
    SORT(tmp);
    if(tmp.front() == tmp.back()) {
        pr((n*K)/2);
        return 0;
    }

    ll ans = 0;
    if(S[0] != S[n-1]){
        Rep(i, 0, n-1){
            if(S[i] == S[i+1]){
                S[i+1] = '#';
                ans++;
            }
        }
        pr(ans*K);
    }else{
        ll a = 1, b = 1;
        REP(i, n){
            if(S[i] == S[i+1]) a++;
            else break;
        }
        RREP(i, n){
            if(S[i] == S[i-1]) b++;
            else break;
        }


        Rep(i, 0, n-1){
            if(S[i] == S[i+1]){
                S[i+1] = '#';
                ans++;
            }
        }

        pr(ans*K - (a/2 + b/2)*(K-1) + ((a+b)/2)*(K-1));
    }
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	ll n;
	ll ans = INF;

	cin >> n;

	vector<ll> v(n, 0);

	REP(i, n) {
		cin >> v[i];
	}

	REP(i, n) {
		ll s1 = 0;
		ll s2 = 0;
		REP(j, i + 1) {
			s1 += v[j];
		}
		FOR(j, i + 1, n) {
			s2 += v[j];
		}
		ans = min(ans, abs(s1 - s2));
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test
{
  public class Program
  {
    public static void Main()
    {
      var n = int.Parse(Console.ReadLine());
      
      for (var countDonut = 0; countDonut * 7 <= 100; countDonut++)
      {
        for (var countCake = 0; countDonut * 7 + countCake * 4 <= 100; countCake++)
        {
          if (countDonut * 7 + countCake * 4 == n)
          {
            Console.WriteLine("Yes");
            return;
          }
        }
      }
      
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13140
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<cstring>
#include<map>
using namespace std;
int   n,m;
vector< int >v[1000000+100];
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].push_back(y);
    }
for (int i=0;i<v[1].size();i++)
{
    int y=v[1][i];
    for (int j=0;j<v[y].size();j++)
    {
        int z=v[y][j];
        if (z==n){cout<<"POSSIBLE"<<endl;return 0;}
    }
}
cout<<"IMPOSSIBLE"<<endl;
return 0;
}


Measured memory_bytes: 27264
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
xy = [LIST() for _ in range(N)]
xy.sort(key=lambda x:(x[0], x[1]))
# print(xy)
delta = defaultdict(int)
if N == 1:
	print(1)
else:
	for i in range(N):
		for j in range(N):
			if i != j:
				delta[(xy[j][0]-xy[i][0], xy[j][1]-xy[i][1])] += 1
	print(1+(N-1)-max(delta.values()))


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			string s = cin.Next();
			int n = s.Length;
			int ans = 0;
			char prev = '$';
			int prevCount = 1;
			for (int i = 0; i < n; i++) {
				if (prevCount == 1) {
					if (s[i] == prev) {
						prevCount = 2;
						++i;
						if (i >= n) {
							break;
						}

						++ans;
						prev = s[i];
					} else {
						prevCount = 1;
						++ans;
						prev = s[i];
					}
				} else {
					++ans;
					prevCount = 1;
					prev = s[i];
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;

int main () {
	int a, b;
	cin >> a >> b;
	int ans;
	if(a != 1 && b != 1) ans = 1;
	if(a != 2 && b != 2) ans = 2;
	if(a != 3 && b != 3) ans = 3;
	cout << ans;
	return 0;
}

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

int dp[1000005];

signed main(){
  
  int k;
  cin >> k;
  
  dp[1] = 7 % k;
  
  for(int i=2;i<1000005;i++) dp[i] = ( dp[i-1] * 10 + 7 ) % k;
  
  for(int i=1;i<1000005;i++){
    if( dp[i] == 0 ){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
  return 0;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int sum[100010];

int main() {
  int N, M;
  cin >> N >> M;
  int l[M], r[M];
  for (int i = 0; i < M; i++) {
    cin >> l[i] >> r[i];
  }

  for (int i = 0; i < M; i++) {
    sum[l[i]]++;
    sum[r[i]+1]--;
  }

 for (int i = 1; i < N + 1; i++) {
   sum[i] += sum[i-1];
 }

 int ans = 0;
 for (int i = 0; i < N + 1; i++) {
   if (sum[i] == M) ans++;
 }

 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, x;
    cin >> n;
    for (int i = 1; i <= n; i++ ){
        if (i % 3 == 0){
            cout << " " << i;
        }else{
            x = i;
            while (x) {
                if (x % 10 == 3){
                    cout << " " << i;
                break;
                }
            x /= 10;
            }
        }
    }
cout << endl;
}


Measured memory_bytes: 3180
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};


int main(){
    IOS;
    make(ll,n);
    makevec(ll,a,n);
    ll op=0;
    while(true){
        bool f=1;
        fr(i,n) if(a[i]!=0) f=0;
        if(f) break;
        ll last=-1; ll mn=INF;
        for(ll i=0;i<n;i++){
            if(a[i]==0) {
                if(last!=-1){
                    for(ll j=last;j<i;j++) a[j]-=mn;
                    op+=mn; mn=INF; last=-1;
                }
            }
            else{
                if(last!=-1){
                    mn=min(mn,a[i]);
                }
                else {last=i; mn=min(a[i],mn);}
            }
        }
        if(last!=-1){
                    for(ll j=last;j<n;j++) a[j]-=mn;
                    op+=mn; mn=INF;

                }
    }
    cout<<op<<endl;


    return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String[] array = reader.readLine().split(" ");
            int N = Integer.parseInt(array[0]);
            int A = Integer.parseInt(array[1]);
            int B = Integer.parseInt(array[2]);

            System.out.println(Math.min(N * A, B));
        }
    }

}


Measured memory_bytes: 21332
// never give up //
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b=0,c=0,n,i,j,k,l;
	vector<long long > v,z;
	
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		
			v.push_back(a);
		b+=a;	
	}
	sort(v.begin(),v.end());
	if(b%10!=0)
	{
		cout<<b;
	return 0;
	}
	
	else
	if(b%10==0)
	for(i=0;i<v.size();i++)
	{
		if((b-v[i])%10!=0)
			z.push_back(b-v[i]);
		else
		c+=b;
		
		
	}
	if(z.size()==0)
	cout<<0;
	else
	for(i=0;i<z.size();i++)
	{
		cout<<z[0];
		return 0;
	}
 
}

Measured memory_bytes: 256
import bisect
sieve=[1]*1000001
i=2
while i*i<=1000001:
    if sieve[i]==1:
        for j in range(i*i,1000001,i):
            sieve[j]=0
    i+=1
lol=[]
for i in range(2,1000001):
    if sieve[i]:
        lol.append(i)
        
x=int(input())
y=bisect.bisect(lol,x)
if lol[y-1]==x:
    print(x)
else:    
    print(lol[y])

Measured memory_bytes: 51292
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(L: int, R: int, d: int):
    ret = R // d - (L - 1) // d
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(L, R, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Integer n = null;
		Integer x = null;
		Integer y = null;
		boolean err = false;
        Scanner scan = new Scanner(System.in);
        String[] sl = scan.nextLine().split(" ");
		try {
			n = Integer.parseInt(sl[0]);
			x = Integer.parseInt(sl[1]);
			y = Integer.parseInt(sl[2]);
		}
		catch (Exception e) {
			System.out.println("不正な入力が含まれています。");
			err = true;
		}

		if (err == false) {
		// 最大値と最小値を求める
			Integer max;
			Integer min;

			if (x < y){
				max = x;
			}
			else {
				max = y;
			}


			if (x + y <= n) {
				min = 0;
			}
			else {
				min = (x + y) - n;
			}

			System.out.println(max + " " + min);
		}
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;	
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		if(n%i == 0){
			if(i >= 1 && i <= 9 && (n/i) >= 1 && (n/i) <= 9)
				return cout << "Yes", 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
int N;
cin >> N;
int h[N];
int mh=0;
rep(i,N){
    cin >> h[i];
    mh=max(mh,h[i]);
}
int count;
long long Ans=0;
int sec=0;
rep(i,mh){
count=0;
sec=0;
    rep(i,N){
        if(h[i]>0 && sec==0){
           count++;
       } 
        if(h[i]>0){
            sec++;
        }
        else{
            sec=0;
        }

    }
    Ans+=count;

    rep(i,N){
        h[i]=max(h[i]-1,0);
    }

}

cout << Ans<<endl;
    

 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  long long n,k,i,res=0;
  cin >> n >> k;
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  for(i=k+1;i<=n;i++)
    res+=n/i*(i-k)+max(n%i-k+1,(long long)0);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
str = input()

total_coins = 0
numbers = str.split(" ")
a = int(numbers[0])
b = int(numbers[1])

if a > b:
  total_coins += a
  a -= 1
else:
  total_coins += b
  b -= 1

if a > b:
  total_coins += a
  a -= 1
else:
  total_coins += b
  b -= 1

print(total_coins)
  

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

typedef long long ll;

int main() {
    ll A;
    string S;
    cin >> A >> S;
    int B = 0;
    B += S[0] - '0';
    B *= 10;
    B += S[2] - '0';
    B *= 10;
    B += S[3] - '0';
    ll ans = A * B;
    ans /= 100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
import math


def main():
    n = int(input())

    n_sqrt = math.sqrt(n)
    ans = n
    for i in range(1, math.ceil(n_sqrt)+1):
        if n%i == 0:
            a = i
            b = n/i
            ans = min(ans,a+b-2)
    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060