akhauriyash/Code-Regression huggingface dataset:
#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 vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 pb push_back
#define pp 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;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

	int N,M; cin >> N >> M;
	vi s(M); vec c(M); rep(i,M) cin >> s[i] >> c[i];

	if(N == 1) {
		bool flag = true;
		rep(i,M) if(c[i] != '0') flag = false;
		if(flag) {
			cout << 0 << endl;
			return 0;
		}
	}

	vector<pair<int,char>> v(M);
	rep(i,M) v[i].fs = s[i], v[i].sc = c[i];

	sort(all(v));

	rep(i,M-1) {
		if(s[i] == s[i+1] and c[i] != c[i+1]) dame
	}


	string ans = "1";
	rep(i,N-1) ans += '0';

	rep(i,M) {
		if(s[i] == 1 and c[i] == '0') dame
		ans[s[i]-1] = c[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n, l, t, a[100001], cnt;
int main(int argc, char const *argv[])
{
    scanf("%d%d%d", &n, &l, &t);
    for (int i = 1; i <= n; i++)
    {
        int op;
        scanf("%d%d", &a[i], &op);
        a[i] += op == 1 ? t : -t;
        cnt += a[i] / l;
        if (a[i] % l < 0)
        {
            cnt--;
        }
        a[i] = (a[i] % l + l) % l;
    }
    sort(a + 1, a + n + 1);
    cnt = (cnt % n + n) % n;
    for (int i = cnt + 1; i <= n; i++)
    {
        printf("%d\n", a[i]);
    }
    for (int i = 1; i <= cnt; i++)
    {
        printf("%d\n", a[i]);
    }
    return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll X,K;
  cin>>X>>K;
  vector<ll> T(K+1,0);
  for(int i=1;i<=K;i++){cin>>T[i];}
  vector<ll> A1(K+1,X);
  vector<ll> A2(K+1,0);
  vector<ll> up(K+1,X);
  vector<ll> lw(K+1,0);
  for(int i=1;i<=K;i++){
    ll dif=T[i]-T[i-1];
    ll sand=A1[i-1];
    if(i&1){
      sand-=dif;
      up[i]=up[i-1];
      sand=max(sand,0LL);
      A1[i]=sand;
    }
    else{
      sand+=dif;
      up[i]=up[i-1]-max(sand-X,0LL);
      sand=min(sand,X);
      A1[i]=sand;
    }
    sand=A2[i-1];
    if(i&1){
      sand-=dif;
      lw[i]=lw[i-1]+max(-sand,0LL);
      sand=max(sand,0LL);
      A2[i]=sand;
    }
    else{
      sand+=dif;
      lw[i]=lw[i-1];
      sand=min(sand,X);
      A2[i]=sand;
    }
    if(lw[i]<=up[i]){assert(up[i]-lw[i]==A1[i]-A2[i]);}
    else{assert(A1[i]==A2[i]);}
  }
  ll Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    ll t,a;
    cin>>t>>a;
    ll idx=upper_bound(T.begin(),T.end(),t)-T.begin(); idx--;
    ll sand;
    if(lw[idx]<a && a<up[idx]){sand=A1[idx]-(up[idx]-a);}
    else if(a<=lw[idx]){sand=A2[idx];}
    else{sand=A1[idx];}
    ll dif=t-T[idx];
    if(idx&1){sand+=dif; sand=min(sand,X);}
    else{sand-=dif; sand=max(sand,0LL);}
    cout<<sand<<endl;
  }

  
  return 0;
}


Measured memory_bytes: 5248
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
int n, a[8], b[8], c[8];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)c[i] = i + 1;
	int s, d, cnt = 0;
	do {
		cnt++;
		int a1 = 0, a2 = 0;
		rep(i, n) {
			if (a[i] == c[i])a1++;
			if (b[i] == c[i])a2++;
		}
		if (a1 == n) { s = cnt; }
		if (a2 == n) { d = cnt; }
	}while (next_permutation(c, c + n));
	cout << abs(s - d) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,i,j;
    cin>>n;
    vector<ll> a(n+1);
    for(i=1;i<=n;i++) cin>>a[i];
    map<ll,ll> mp;
    ll ans =0;
    for(i=1;i<=n;i++)
    {
        mp[i-a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        mp[i-a[i]]--;
        ans+=mp[i+a[i]];
    }
    cout<<ans;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,X,L[111];
ll i, j, k, ans;
int main(){
    scanf("%lld%lld", &N,&X);
    ans = 1;
    fornum(i,0,N){
        scanf("%lld", &L[i]);
        j += L[i];
        if(j<=X){
            ans++;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll h[309];
ll a[309][309];
void solve()
{
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	for(ll i=0;i<=(n+1);i++)
	{
		for(ll j=0;j<=k;j++)
		{
			a[i][j]=inf;
		}
	}
	a[0][0]=0;
	ll ans=inf;
	for(ll i=0;i<=(n+1);i++)
	{
		for(ll j=0;j<=k;j++)
		{
			for(ll l=0;l<=k;l++)
			{
				if((j+l)>k)
					break;
				if((i+l+1)>(n+1))
					break;
				a[i+l+1][j+l]=min(a[i+l+1][j+l],a[i][j]+max((ll)0,h[i+l+1]-h[i]));
			}
			if(i==(n+1))
				ans=min(ans,a[i][j]);
		}
	}
	cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}


Measured memory_bytes: 4388
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	} else if (a * b == 15) {
		cout << "*" << endl;
	} else {
		cout << "x" << endl;
	}
	return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct Node {
    ll key;
    Node *parent, *left, *right;
};
Node *NIL, *root;

void insert(ll k){
    Node *y = NIL;   // xの親
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));   // Node分のポインタの容量をとる
    z->key = k; z->left = NIL; z->right = NIL;

    while(x != NIL){
        y = x;  // 親を設定
        if((z->key) < (x->key)){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL) root = z;
    else if(y->key > z->key) y->left = z;
    else y->right = z;
}

void preorder(Node *n){
    if(n == NIL) return;
    printf(" %ld", n->key);
    preorder(n->left);
    preorder(n->right);
}

void inorder(Node *n){
    if(n == NIL) return;
    inorder(n->left);
    printf(" %ld", n->key);
    inorder(n->right);
}

int main()
{
    int m; cin >> m;
    rep(i,m){
        string c; cin >> c;
        if(c == "insert"){
            ll k; cin >> k;
            insert(k);
        }else if(c == "print"){
            inorder(root); cout << endl;
            preorder(root); cout << endl;
        }
    }
}


Measured memory_bytes: 26776
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    cin>>a>>b>>c;
    d=a+b;
    e=a+c;
    f=b+c;
    if(d<e && d<f){
        cout<<d;
    }
    else if(e<d && e<f){
        cout<<e;
    }
    else if(f<d && f<e){
        cout<<f;
    }
    else if(d==e || d==f ||f==d){
        cout<<d;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));

            int A = Integer.parseInt(input.get(0));
            int B = Integer.parseInt(input.get(1));
            int T = Integer.parseInt(input.get(2));

            int result = 0;
            while (T >= A) {
                result += B;
                T -= A;
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22996
import sys
import bisect

_input = sys.stdin.readlines()
A, B, Q = [int(i) for i in _input[0].split()]
data = [int(i) for i in _input[1:]]
"""
A, B, Q = [int(i.strip()) for i in input().split()]
data = list()
for l in range(A+B+Q):
    data.append(int(input()))
"""
s_ls = sorted(data[:A] + [1e30,-1e30])
t_ls = sorted(data[A:A+B] + [1e30,-1e30])
x_ls = data[-Q:]

for x in x_ls:
    s_pos = bisect.bisect_left(s_ls, x)
    s_left = s_ls[s_pos-1]
    s_right = s_ls[s_pos]
    t_pos = bisect.bisect_left(t_ls, x)
    t_left = t_ls[t_pos-1]
    t_right = t_ls[t_pos]
    a = abs(x - min(s_left, t_left))
    b = abs(x- max(s_right, t_right))
    c = abs(x - s_left) + abs(x - t_right) + min(abs(x - s_left), abs(x - t_right))
    d = abs(x - t_left) + abs(x - s_right) + min(abs(x - t_left), abs(x - s_right))
    dis = min(a,
              b,
              c,
              d)
    print(dis)

Measured memory_bytes: 42380
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    long long n,m;
    cin>>n>>m;
    if(n > m)
        swap(n,m);
    if(n == 1&&m>=2)
        cout<<(m-2)<<endl;
    else if(n == 1&&m == 1)
        cout<<"1"<<endl;
    else
        cout<<n*m - (2ll*(n+m) - 4ll)<<endl;
    return 0;
}


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

int L[4][5] = {
	{1,4,7,10,16},
	{3,6,9,12,13},
	{1,2,3,15,19},
	{7,8,9,10,13}
};

int R[4][5] = {
	{24,27,30,21,18},
	{22,25,28,19,15},
	{28,29,30,16,21},
	{22,23,24,12,18}
};

struct Cube {
	int cube[31], s;
	
	Cube() {}
	
	inline void rot(int t) {
		for(int i=0;i<5;++i) swap(cube[L[t][i]], cube[R[t][i]]);
	}
	
	inline bool fail(int a, int b) {
		for(int i=a+1;i<=b;++i) if (cube[a] != cube[i]) return 1;
		return 0;
	}
	
	inline bool solved() {
		if (fail(1,9)) return 0;
		if (fail(10,12)) return 0;
		if (fail(13,15)) return 0;
		if (fail(16,18)) return 0;
		if (fail(19,21)) return 0;
		if (fail(22,30)) return 0;
		return 1;
	}
};

int main() {
	int N;
	cin >> N;
	
	for(int i=0;i<N;++i) {
		Cube ini;
		for(int i=1;i<=30;++i) cin >> ini.cube[i];
		ini.s = 0;
		
		queue< Cube > q;
		q.push(ini);
		
		while (!q.empty()) {
			Cube c = q.front(); q.pop();
			
			if (c.solved()) {
				cout << c.s << endl;
				break;
			}
			
			++c.s;
			
			for(int i=0;i<4;++i) {
				c.rot(i);
				q.push(c);
				c.rot(i);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 12164
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using pii = pair<int,int>; 
using db = double; 
using vi = vector<int>; 
#define fir first
#define sec second
#define pb push_back
#define lowbit(x) ((x)&(-(x))) 

int n, m; 
int g[400][400]; 
int a[400][400]; 
int d[400]; 
bool v[400]; 

int main() {
	scanf( "%d%d", &n, &m ); 
	for (int i = 1; i <= n; ++i) 
		for (int j = 1; j <= m; ++j) scanf( "%d", &a[i][j] );  
	int ans = n+1; 
	for (int i = 0; i < m; ++i) {
		memset(d, 0, sizeof(d)); 
		for (int j = 1; j <= n; ++j)
			for (int p = 1; p <= m; ++p) 
				if (!v[a[j][p]]) {
					d[a[j][p]]++; 
					break; 
				}
		int k = 1; 
		for (int j = 2; j <= m; ++j) 
			if (d[j] > d[k]) k = j; 
		ans = min(ans, d[k]); 
		v[k] = true; 
	}
	cout<<ans<<endl; 
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int>v(N);
    for(int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    vector<int> copy(N);
    for(int i = 0; i < N; i++)
    {
        copy[i] = v[i];
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int a ;
    int ma;
    a = v[0];
    ma = v[1];



    for(int i = 0; i < N; i++)
    {
        if(copy[i] == a)
            cout << ma << endl;
        else
            cout << a << endl;
    }

}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int H, W, N;
string town[1024];
int dist[10][1024][1024];

inline bool in(int r, int c) {
  return 0 <= r && r < H && 0 <= c && c < W;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> H >> W >> N;
  REP(i, H) cin >> town[i];
  int sr = 0, sc = 0;
  REP(i, H) REP(j, W) {
    if (town[i][j] == 'S') {
      sr = i, sc = j;
      break;
    }
  }

  int ans = 0;
  REP(i, N) {
    queue<T> que;
    que.push(T(sr, sc, 1));
    while (!que.empty()) {
      int r, c, d;
      tie(r, c, d) = que.front(); que.pop();
      if (dist[i][r][c]) continue;
      dist[i][r][c] = d;
      if ('1' <= town[r][c] && town[r][c] <= '9' && town[r][c] - '0' == i+1) {
	ans += d-1;
	sr = r, sc = c;
	break;
      }
      REP(j, 4) {
	int nr = r + dr[j], nc = c + dc[j];
	if (in(nr, nc) && town[nr][nc] != 'X' && !dist[i][nr][nc]) {
	  que.push(T(nr, nc, d+1));
	}
      }
    }
  }

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

Measured memory_bytes: 39132
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int ll;
int N;ll L;
ll Len[100002];
vector<int>Chn;
ll Lensum[100002];
ll ans;
int main()
{
	scanf("%d%lld", &N,&L);
	for (int i = 1; i <= N; i++)scanf("%lld", &Len[i]);
	for (int i = 1; i <= N; i++)Lensum[i] = Lensum[i - 1] + Len[i];
	Chn.push_back(1);
	for (int i = 1; i <= N; i++){
		if (Len[i - 1]<Len[i] && Len[i]>Len[i + 1])Chn.push_back(i);
		else if (Len[i - 1] > Len[i] && Len[i] < Len[i + 1])Chn.push_back(i);
	}
	Chn.push_back(N);
	for (int i = 1; i < Chn.size(); i++){
		ans = max(ans, (ll)(Chn[i] - Chn[i - 1]+1)*L - Lensum[Chn[i]] + Lensum[Chn[i - 1]-1]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n;
	cin>>n;
	int b=0, c=0;
	for(int i=1;i<=n;i++){
		b=0;
		if(i%2==0)
			continue;
		for(int j=1;j<=i;j++){
			if(i%j==0)
				b++;	
		}
		if(b==8)
			c++;
	}
	cout<<c<<endl;
	return 0;
}

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

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

  vector<int> V(N), C(N), D(N);
  rep(i, N) cin >> V[i];
  rep(i, N) cin >> C[i];

  rep(i, N) D[i] = V[i] - C[i];

  sort(D.rbegin(), D.rend());

  int sum = 0;
  rep(i, N) {
    if (sum < sum + D[i])
      sum += D[i];
  }

  cout << sum << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll k4 = 0;
  ll k2 = 0;
  ll k1 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 4 == 0) {
      k4++;
    } else if (a[i] % 2 == 0) {
      k2++;
    } else {
      k1++;
    }
  }
  if (k4 + 1 == k1 && n == (k4 + k1)) {
    cout << "Yes" << endl;
    return 0;
  } else {
    if (k4 < k1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1024
/*#include <iostream>
using namespace std;
int main() {
	char X,Y;
	cin >> X;
	cin >> Y;
	if (X > Y) {
		cout << ">";
		return 0;
	}
	if (X < Y) cout << "<";
	else cout << "=";

	return 0;
}	*/
/*
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>p;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		p.push_back(a);
	}
	sort(p.begin(), p.end());
	int suma= 0;
	bool b =true;
	for (int i = N-1; i >=0; i--) {
		if (b) {
			suma += p[i];
			b = false;
		}
		else {
			suma -= p[i];
			b = true;
		}
	}

	cout << suma;

	return 0;
*/

	#include <iostream>
	#include <algorithm>
	#include <vector>
	using namespace std;

	int main() {
		int N;
		cin >> N;
		vector<int>p;
		vector < int>t;
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			p.push_back(a);
			if (a % 10 != 0) {
				t.push_back(a);
			}
		}
		int suma = 0;
		for (int i =0; i <N; i++) 
		{
			suma += p[i];
		}
		sort(t.begin(), t.end());
		
		if (suma % 10 == 0 && !t.empty()) {
			suma -= t[0];
			cout << suma << endl;

		}
		else if (t.empty()) {
			cout << 0 << endl;
	
		}
		else cout << suma << endl;
		
		return 0;
	}	

Measured memory_bytes: 3624
#pragma GCC optimize(2)
#define LOCAL0
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define xx first 
#define yy second
#define INF 0x3f3f3f3f
void read(int &p)
{
    p=0;int flag=1;char c=getchar();
    while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();}
    while(isdigit(c)) {p=p*10+c-'0';c=getchar();}p*=flag;
}
ll x,y;

ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return max(a,b)/gcd(a,b)*min(a,b);
}

int main()
{
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    while(cin>>x>>y) printf("%lld %lld\n",gcd(x,y),lcm(x,y));
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}

void solve() { 
	int a, b;
	cin >> a >> b;
	cout << (a * b) / __gcd(a, b);    
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int x = s.nextInt();
        int result = 0;
        for(int i = 0;i < n; i++) {
            int ele = s.nextInt();
            ele = abs(x-ele);
            if(i != 0) {
                result = gcd(result,ele);
            } else {
                result = ele;
            }
        }
        System.out.println(result);
    }
    static int gcd(int a, int b) {
        if(a == 0)
            return b;
        return gcd(b%a,a);
    }
    static int abs(int a) {
        return a < 0 ? -a : a;
    }
}


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

int a[100000];
ll fact[100000];
ll bit[100001];
int n;

void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i&-i;
	}
}
int sum(int i) {
	int s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i&-i;
	}
	return s;
}
int main() {
	while (scanf("%d", &n), n) {
		int r; scanf("%d", &r);
		rep(i, n) {
			a[i] = i;
			add(i + 1, 1);
		}
		rep(i, r) {
			int s, t; scanf("%d%d", &s, &t); s--; t--;
			swap(a[s], a[t]);
		}
		fact[0] = 1;
		for (int i = 1; i < n; i++)fact[i] = (fact[i - 1] * i) % MOD;
		ll cnt = 0;
		rep(i, n) {
			int d = sum(a[i]);
			cnt = (cnt + fact[n - i - 1] * d) % MOD;
			add(a[i] + 1, -1);
		}
		printf("%lld\n", cnt);
	}
}

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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(a-x)<abs(b-x)){
    cout << "A";
  }
  else if(abs(a-x)>abs(b-x)){
    cout << "B";
  }
  cout << endl;
  return 0;
}

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


int main(){
  long double a,b,c;
  scanf("%llf%llf%llf",&a,&b,&c);
  
  //printf("%d %d %d\n",a,b,c);
  //printf("%f\n",sqrt(0.5));
  long double asq,bsq,csq;
  asq = sqrt(a);
  bsq = sqrt(b);
  csq = sqrt(c);
  //printf("%llf %llf %llf\n",asq,bsq,csq);
  if (a + b + 2.00000000000000000000*asq*bsq  < c){
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 256
H,W,D=map(int,input().split())
A=[[] for _ in range(H)]

for i in range(H):
    A[i]=list(map(int,input().split()))
    
index=[[-1,-1] for _ in range(H*W+1)]

for i in range(H):
    for j in range(W):
        index[A[i][j]]=[i,j]
        
    
S=[[0]*(H*W//D+1) for _ in range(D+1)]
for start in range(1,D+1):
    for j in range(H*W//D):
        prev=start+j*D
        nxt=prev+D
        if nxt>H*W:
            break
        diff=abs(index[nxt][0] - index[prev][0]) + abs(index[nxt][1] - index[prev][1])
        S[start][j+1]=S[start][j]+diff
        
Q=int(input())
        
for i in range(Q):
    L,R=map(int,input().split())
    start=L%D
    if start==0:
        start=D
    print(S[start][(R-start)//D] - S[start][(L-start)//D])
    
    
    
    

Measured memory_bytes: 74988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

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


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

using namespace std;

using LD = long double;

int main() {

	ios_base :: sync_with_stdio(0);
	cin.tie(NULL);

	cout << fixed;
	cout << setprecision(10);

	LD A, B, H, M;
	cin >> A >> B >> H >> M;

	LD hour_ang = (M_PI / 180.0) * ((H * 360.0) / 12.0) + ((M * 30.0) / 60.0) * (M_PI / 180.0);
	LD min_ang  = (M_PI / 180.0) * ((M * 360.0) / 60.0);

	LD ax = A * cos(hour_ang);
	LD ay = A * sin(hour_ang);

	LD bx = B * cos(min_ang);
	LD by = B * sin(min_ang);

	LD a = ax - bx;
	LD b = ay - by;

	LD r = a * a + b * b;
	cout << sqrt(r) << '\n';



	return 0;	
}

Measured memory_bytes: 4184
import java.util.Scanner;

class Main {

    static Scanner scan;
    static P[] p;
    static int head;
    static int tail;

    public static void main(String[] args) {
	int elaps = 0;
	
	// get from std in: n, q
	scan = new Scanner(System.in);
	final int n = scan.nextInt();
	final int q = scan.nextInt();

	// create a queue
	p = new P[100000];
	head = 0;
	tail = n;

	for (int i = 0; i < n; i++) {
	    String name = scan.next();
	    int t = scan.nextInt();
	    p[i] = new P(name, t);
	}

	while(head != tail) {
	    P u = dequeue();
	    int c = min(q, u.t);
	    u.t -= c;
	    elaps += c;
	    if(u.t > 0) enqueue(u);
	    else {
		System.out.printf("%s %d\n", u.name, elaps);
	    }
	}
    }

    static void enqueue(P x) {
	p[tail] = x;
	tail = (tail + 1) % p.length;
    }
    
    static P dequeue() {
	P x = p[head];
	head = (head + 1) % p.length;
	return x;
    }

    static int min(int a, int b) {
	if(a < b) {
	    return a;
	} else {
	    return b;
	}
    }
}

class P {
    public String name;
    public int t;

    public P(String name, int t) {
	this.name = name;
	this.t = t;
    }
}



Measured memory_bytes: 115928
#!/usr/bin/env python3
import sys


def solve(K: int):
    if K % 2 == 0:
        print(-1)
    else:
        num = 7
        cnt = 1
        stop = 10 ** 7
        while cnt < stop:
            if num % K == 0:
                print(cnt)
                return
            else:
                num *= 10
                num += 7
                num %= K
                cnt += 1
        print(-1)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

Measured memory_bytes: 62996
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1e18;
//const ll mod = 1000000007;

 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> num(N+1);
    for(ll i = 1; i <= N; i++) {
        for(ll j = i; j <= N; j += i) {
            num[j]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= N; i++) {
        ans += i * num[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int main() {

	ll H;
	scanf("%lld", &H);

	ll l = 1;

	while(l <= H) l *= 2;

	printf("%lld\n", l - 1);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

vector<int> v;

void make_753(int i, string s){
    if(i==0){
        if (s.find("7") == std::string::npos) return;
        if (s.find("5") == std::string::npos) return;
        if (s.find("3") == std::string::npos) return;
        v.push_back(stoi(s));
        return;
    }
    make_753(i-1, s+"7");
    make_753(i-1, s+"5");
    make_753(i-1, s+"3");
}

int main(void){
    rep1(i,9){
        make_753(i,"");
    }
    sort(all(v));
    int n;
    cin>>n;
    cout << ub(v,n) << endl;

    return 0;
}


Measured memory_bytes: 640
//abc115_c.cpp
//Sat Dec 15 19:18:11 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	sort(h,h+n);

	int ans = INTINF;
	int prevhight = 0;
	for (int i=0;i<n-k+1;i++){
		if (prevhight==h[i]){
			continue;
		}
		if (ans > h[i+k-1]-h[i]){
			ans = h[i+k-1]-h[i];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<ll>;
using m = map<int,int>;
using vv = vector<v>;

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    auto a = v(n,0);
    for (int i = 0; i < q; i++)
    {
        int t =0;
        cin >> t;
        a[t-1]++;
    }
    for (int i = 0; i < n; i++)
    {
        cout <<(q-a[i]<k?"Yes":"No")<<endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9 #define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans = w * h / 2.0;
	printf("%.10lf ", ans);
	double dx = w / 2.0;
	double dy = h / 2.0;
	if (dx == x and dy == y) cout << 1 << endl;
	else cout << 0 << endl;

	

}


Measured memory_bytes: 256
#include <algorithm>
    #include <iostream>
    #include <string>
    using namespace std;
     
    int main() {
    	string s;
    	cin >> s;
    	sort(s.begin(), s.end());
    	
    	string t;
    	cin >> t;
    	sort(t.begin(), t.end());
    	reverse(t.begin(),t.end());
    	
    	if (s < t) cout << "Yes" << endl;
    	else cout << "No" << endl;
    }


Measured memory_bytes: 256
N,*E=map(int,open(0).read().split())
E=sorted((e,2*(i<N)-1)for i,e in enumerate(E))
a,c=1,0
for _,d in E:
	if c*d<0:a=(a*abs(c))%(10**9+7)
	c+=d
print(a)

Measured memory_bytes: 25948
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef pair<char, int> P;
P v1[40], v2[40];
int n;

void bubbleSort() {
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = n - 1; j >= i + 1; j--) {
			if (v1[j - 1].second > v1[j].second) {
				swap(v1[j - 1], v1[j]);
			}
		}
	}
}

void selection() {
	int i, j, minj;
	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i + 1; j < n; j++) {
			if (v2[minj].second > v2[j].second) {
				minj = j;
			}
			
		}
		swap(v2[i], v2[minj]);
	}
}

bool compare() {
	for (int i = 0; i < n; i++) {
		if (v1[i].first != v2[i].first) {
			return false;
		}
	}
	return true;
}

int main() {

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v1[i].first >> v1[i].second;
		v2[i] = v1[i];
	}
	bubbleSort();
	selection();
	for (int i = 0; i < n; i++) {
		cout << v1[i].first << v1[i].second;
		if (i < n - 1) cout << ' ';
	}
	cout << endl << "Stable" << endl;
	for (int i = 0; i < n; i++) {
		cout << v2[i].first<< v2[i].second;
		if (i < n - 1) cout << ' ';
	}
	cout << endl;
	if (compare()) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}



Measured memory_bytes: 3120
#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 = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

const int MAX = 3010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<mint>> dp(n+1, vector<mint>(MAX));
  dp[0][0] = 1;
  rep(i, n) {
    rep(j, MAX) {
      dp[i+1][j] += dp[i][j]*2;
      if (a[i]+j < MAX)
        dp[i+1][a[i]+j] += dp[i][j];
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}

Measured memory_bytes: 38576
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int[] hw = IO.INT(' ');
        string[] m = IO.STRING(hw[0]);
        int n = 0;
        string o = "Possible";
        for (int i = 0; i < hw[0]; i++)
        {
            bool start = false;
            for (int j = 0; j < hw[1]; j++)
            {
                if (m[i][j] == '#' && !start)
                {
                    if (j < n)
                    {
                        o = "Impossible";
                        break;
                    }
                    start = true;
                }
                if (m[i][j] == '#' && j == hw[1] - 1)
                {
                    n = j;
                }
                if (start && m[i][j] == '.')
                {
                    n = j - 1;
                    start = false;
                }
            }
            if (o == "Impossible")
            {
                break;
            }
        }
        IO.WRITE(o);
        IO.FLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(object s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

Measured memory_bytes: 3032
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N, M, K, ret = 0;
char grid [10][10];

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> M >> K;
    for(int i = 0; i < N; i++) cin >> grid[i];
    for(int a = 0; a < (1<<N); a++)
        for(int b = 0; b < (1<<M); b++){
            int cnt = 0;
            for(int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++)
                    if (grid[i][j] == '#' && (a & (1 << i)) == 0 && (b & (1 << j)) == 0)
                        cnt++;
            }
            if(cnt == K) ret++;
        }
    cout << ret << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    ll n;
    cin >> n;
    ll ans = n - 1;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) ans = min(ans, i + n / i - 2);
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const ll MOD = 1000000007;

const double PI = 3.1415926535897932;
/******define variable start******/
ll n;
vl p, q;
/*******define variable end*******/
ll solve(){
    cin >> n;
    p.resize(n);
    q.resize(n);
    REP(i, n){
        cin >> p[i];
    }
    REP(i, n){
        cin >> q[i];
    }
    int array[n];
    for(ll i = 1; i < n+1; i++){
        array[i-1] = i;
    }
    ll a = 0;
    ll b = 0;
    ll count = 0;
    do {
        count++;
        ll pcount = 0;
        ll qcount = 0;
        for (ll i = 0; i < n; i++) {
            if(array[i] == p[i]){
                pcount++;
            }
            if(array[i] == q[i]){
                qcount++;
            }
        }
        if(pcount == n){
            a = count;
        }
        if(qcount == n){
            b = count;
        }
    }while (std::next_permutation(array, array + n));
    cout << abs(b - a) << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int N;
int a[200000];
int ans = -1;

void solve(){
	int wanted = 1;//来て欲しい数
	int breaking_counter = 0;//壊す回数
	for(int i=0;i<N;i++){
		if(a[i]==wanted){
			wanted++;
		}else{
			breaking_counter++;
		}
	}
	if(breaking_counter==N) ans = -1;
	else ans = breaking_counter;
}

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

	solve();

	cout << ans;
	return 0;
}

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

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

vector<int> to[100005];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for(auto u: to[v]){
            if(dist[u]!=INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i==0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10500