akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <stack>
#include <cassert>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 2e3 + 10;

int n, p[maxn], a[maxn];
int deg[maxn], dep[maxn], pos[maxn], bot[maxn], top[maxn];
bool exist[maxn], red[maxn], sorted[maxn];
vector<int> opt;

void Rotate(int u)
{
	opt.push_back(u);
	int tmp = a[0];
	stack<int> sta;
	while (true)
	{
		sta.push(u);
		if (!u) break;
		u = p[u];
	}
	while (true)
	{
		u = sta.top();
		sta.pop();
		if (sta.empty())
		{
			a[u] = tmp;
			break;
		}
		a[u] = a[sta.top()];
	}
}

void Clear()
{
	for (int i = n; ~ i; -- i)
		if (exist[i] && !deg[i] && a[i] == i)
		{
			exist[i] = false;
			-- deg[p[i]];
		}
}

bool cmp(const int &a, const int &b)
{
	if (red[a] != red[b]) return red[a];
	return dep[a] > dep[b];
}

bool Doit()
{
	Clear();
	if (!exist[0]) return false;
	for (int i = 0; i < n; ++ i)
		red[i] = sorted[i] = false;
	int tot = 0;
	for (int i = n - 1; ~ i; -- i)
	{
		if (!exist[i]) continue;
		pos[tot ++] = i;
		if (!deg[i])
		{
			red[i] = true;
			bot[i] = top[i] = i;
		}
		if (!red[i]) continue;
		if (deg[p[i]] == 1)
		{
			red[p[i]] = true;
			bot[p[i]] = bot[i];
		}
	}
	sort(pos, pos + tot, cmp);
	for (int i = 0; i < tot; )
	{
		if (red[a[0]])
		{
			int u = bot[a[0]];
			while (sorted[u] && a[u] > a[0]) u = p[u];
			Rotate(u);
			u = bot[u];
			sorted[top[u]] = true;
			top[u] = p[top[u]];
		}
		else Rotate(pos[i ++]);
		while (i < tot && sorted[pos[i]]) ++ i;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; ++ i) exist[i] = true;
	for (int i = 1; i < n; ++ i)
	{
		cin >> p[i];
		++ deg[p[i]];
		dep[i] = dep[p[i]] + 1;
	}
	for (int i = 0; i < n; ++ i) cin >> a[i];
	Doit();
	while (Doit());
	for (int i = 0; i < n; ++ i) assert(a[i] == i);
	assert(opt.size() <= 25000);
	cout << opt.size() << endl;
	for (int i = 0; i < opt.size(); ++ i)
		cout << opt[i] << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>
#define forn    for(int i=0;i<n;i++)

 int main()
{
ll k;
cin>>k;
string s;
cin>>s;
if(s.size()<=k){
  cout<<s<<endl;
}
else {
  for(int i=0;i<k;i++){
  cout<<s[i];
  }
  cout<<"..."<<endl;
}
}






Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	long long n;
	cin>>n;
	long long ans=(1+n)*n/2;
	long long cnt1=n/3,tmp1=n-n%3,cnt2=n/5,tmp2=n-n%5,cnt3=n/15,tmp3=n-n%15;
	ans=ans-(cnt1*(3+tmp1)/2);
	ans=ans-(cnt2*(5+tmp2)/2);
	ans=ans+(cnt3*(15+tmp3)/2);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3772
#include <iostream>
using namespace std;
int main()
{

  int a,b,c;
  int x1,x2,y;

  cin >> a >> b >> c;

  if ( a >= b && b >= c ) {
      x1 = a;
      x2 = b;
      y = c;
  } else if ( a >= c && c >= b ) {
      x1 = a;
      x2 = c;
      y = b;
  } else if ( b >= a && a >= c ) {
      x1 = b;
      x2 = a;
      y = c;
  } else if ( b >= c && c >= a ) {
      x1 = b;
      x2 = c;
      y = a;
  } else if ( c >= a && a >= b ) {
    x1 = c;
    x2 = a;
    y = b;
  } else if ( c >= b && b >= a ) {
    x1 = c;
    x2 = b;
    y = b;
  }

  cout << ((x1*10)+x2)+y << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	int N;
	int h[110]={};
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> h[i];
	}
	
	for(int k=0;k<100;k++)
	{
		for(int i=0;i<N;i++)
		{
			if(h[i+1]==0 && h[i]!=0)ans++;
			if(h[i]>0)
			{
				h[i]--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



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

#define pb push_back
#define mp make_pair
#define F(i, a, n) for(int i=a;i<n;i++)
#define REP(i, n) F(i, 0, n)
#define REP1(i, n) for(int i=1;i<=n;i++)
#define REV(i, n) for(int i=n;i>=0;i--)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const ll MAX = 1e6 + 5;

int n;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	cout<<n*800 - n/15*200;
	return 0;
}

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

#define ll long long

int n;
int b[100005];

int main() {
  cin >> n;

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

  b[0]--;
  for (int i = 1; i < n; i++) {
    if (b[i] < b[i-1]) {
      cout << "No" << endl;
      return 0;
    }
    if (b[i] > b[i-1]) {
      b[i]--;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long f[333][333][333];

long long solution(int n,int x,int y){
  f[0][1][0]=1;
  for(int i=0;i<=n;i++)
    for(int j=1;j<=x;j++)
      for(int p=i;p>=0;p--){
          if(p) (f[i][j][p-1]+=f[i][j][p]) %= y;
          else (f[i][j+1][i]+=f[i][j][p]) %= y;
          (f[i+1][j][p]+=f[i][j][p]*(p+1)) %= y;
      }
  return f[n][x + 1][n];
}

int main()
{
  int n, x ,y;
  n = 197;
  x = 73;
  y = 82195333;
  cin>>n>>x>>y;
  long long res = solution(n, x, y);
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 262272
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := make([]int, a+1)
	for i := 0; i < a; i++ {
		b[i] = nextInt()
	}
	c := 0
	f := true
	for f == true {
		for i := 0; i < a; i++ {
			if b[i]%2 == 0 {
				b[i] = b[i] / 2
			} else {
				f = false
				break
			}
		}
		if f == true {
			c++
		}
	}

	fmt.Fprintf(writer, "%d", c)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

#define max_n 205

int main(void) {
    int i,j,k;
    int n, m, r;
    cin >> n >> m >> r;

    ll dp[max_n][max_n];
    rep(i,max_n)rep(j,max_n) dp[i][j] = (ll)INF*INF;

    vi d(r);
    rep(i,r) cin >> d[i], d[i]--;
    sort(all(d));

    rep(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }
    rep(k,n)rep(i,n)rep(j,n)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    ll ans = (ll)INF*INF;

    do{
        ll tmp = 0;
        rep(i,r-1)
            tmp += dp[d[i]][d[i+1]];
        ans = min(ans, tmp);

    }while(next_permutation(all(d)));

    cout << ans << endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

typedef pair<int,int> P;

signed main(){
	int n,x[100000],ans[100000] = {},su = 0,ansu = 0;
	vector<P> vec;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x[i];
		su += x[i];
		vec.push_back(P(x[i],-i));
	}
	sort(vec.begin(),vec.end(),greater<P>());
	int lind = n,lup = 0,last = vec[0].first,sum = 0;
	for(int i = 0;i < n;i++){
		sum += (last - vec[i].first) * i;
		last = vec[i].first;
		if(!vec[i].second){
			ans[lup] = sum;
			ans[0] = su - ansu - sum;
			break;
		}
		if(lind > -vec[i].second){
			if(i) ans[lup] = sum;
			lup = -vec[i].second;
			ansu += sum;
			sum = 0;
			lind = -vec[i].second;
		}
	}
	for(int i = 0;i < n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int a[3];
    rep(i, 3) scanf("%d", &a[i]);
    sort(a, a+3);

    int ans = a[2] - a[1];
    a[0] += ans;
    ans += div_ceil(a[2]-a[0], 2) + (a[0]%2 != a[2]%2);
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
string s;
int c1[10],c2[100],c3[1000];

void solve(){
  cin >> n;
  cin >> s;
  rep(i,10){
    c1[i]=mod;
  }
  rep(i,100){
    c2[i]=mod;
  }
  rep(i,1000){
    c3[i]=mod;
  }
  rep(i,n){
    c1[s[i]-'0']=min(c1[s[i]-'0'],i);
  }
  rep(i,n){
    rep(j,10){
      if(c1[j]<i){
        c2[10*j+s[i]-'0']=min(c2[10*j+s[i]-'0'],i);
      }
    }
  }
  rep(i,n){
    rep(j,100){
      if(c2[j]<i){
        c3[10*j+s[i]-'0']=min(c3[10*j+s[i]-'0'],i);
      }
    }
  }
  int ans=0;
  rep(i,1000){
    if(c3[i]!=mod){
      ans+=1;
    }
  }
  cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ******************************CODE**********************************//


int main(){
        _upgrade;
        int n;
        cin >> n;
        map<ll,int> mp;
        mp[0] = 1;
        ll s = 0;
        ll ans = 0;
        for(int i = 0; i < n; i++)
        {
                int x;
                cin >> x;
                s += x;
                ans += mp[s];
                mp[s]++;
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 12800
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll dp[55][55][2505];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, a;
	cin >> n >> a;
	vi x(n + 1);
	repn(i, 1, n + 1) cin >> x[i];
	ll ans = 0LL;
	rep(i, 55) rep(j, 55) rep(k, 2505) dp[i][j][k] = 0LL;
	dp[0][0][0] = 1LL;
	repn(j, 1, n + 1){
		rep(k, n + 1){
			rep(l, 2501) dp[j][k][l] += dp[j - 1][k][l]; //don't include it
			if(k){
				for(int l = 2500 - x[j]; l >= 0; l--){
					dp[j][k][l + x[j]] += dp[j - 1][k - 1][l];
				}
			}
		}
	}
	repn(i, 1, n + 1) ans += dp[n][i][i * a];
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 59520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

string a, b;

int main(void){
    
    cin >> a >> b;
    a += b;
    int num = atoi(a.c_str());
    int temp = (int)sqrt((double)num);
    
    if(temp * temp == num) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	string s;
	cin>>n>>s;
	ll ans=1;
	for(ll i=1;i<n;i++)
	{
		if(s[i]!=s[i-1])
			ans++;
	}
	cout<<ans;
    return 0;
}


//252908XL

Measured memory_bytes: 512
H, W = map(int, input().split())
S = [list(map(str, input())) for _ in range(H)]

M = [[0] * (W + 2) for _ in range(H + 2)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            for k in range(3):
                for l in range(3):
                    if k == l == 1:
                        M[i + k][j + l] = '#'
                    else:
                        if M[i + k][j + l] != '#':
                            M[i + k][j + l] += 1

for i in range(1, H + 1):
    for j in range(1, W + 1):
        print(M[i][j], end='')
    print('')

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

fn main() {
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let v: Vec<&str> = input.split_whitespace().collect();

    let s = v[0];
    let a: i32 = v[2].parse().unwrap();
    let b: i32 = v[3].parse().unwrap();
    let u = v[4];
    if s == u { println!("{} {}", a-1, b) }
    else { println!("{} {}", a, b-1) }
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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

const ll MOD = 1e9 + 7;


int main(int argc, char* argv[]) {
	
	int n, k;
	cin >> n >> k;


	ll cnt = 0;
	for (ll i = k; i <= n+1; i++) {
		ll mi = (i * (i - 1)) / 2;

		ll ma = (i * (2 * n - i + 1)) / 2;
		
		cnt = (cnt + ma - mi + MOD + 1) % MOD;
	}
	
	cout << cnt << endl;

}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int n;
    cin>>n;
    vector<int> w(n), s(n), v(n), box(n);
    rep(i,n) cin>>w[i]>>s[i]>>v[i];
    rep(i,n) box[i]=i;
    sort(box.begin(),box.end(),[&](int x,int y){return w[x]+s[x]<w[y]+s[y];});
    vector<vector<ll>> dp(n+1, vector<ll>(20005));
    dp[0][0]=0;
    rep(i,n){
        int ind=box[i];
        rep(j,20005){
            dp[i+1][j]=dp[i][j];
            if(j-w[ind]<=s[ind] && j-w[ind]>=0){ 
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[ind]]+v[ind]);
                }
        }
    }
    ll ans=0;
    rep(j,20005) ans=max(ans,dp[n][j]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 163588
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
   
    int x;
    cin >> x;
    if (x >= 30)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX=1e6;
int dp[MAX];

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

Measured memory_bytes: 11424
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int maxx=-1;
	int flag=1;
	for(int i=1;i<=n;i++){
		int temp=i;
		int kount=0;
		while(temp%2==0){
			temp/=2;
			kount++;
		}
		if(kount>maxx){
			maxx=kount;
			flag=i;
		}
	}
	printf("%d",flag);

return 0;
}

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

int main() {
    string s;
    cin >> s;
    bool flag = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'L' && i%2 == 0) flag = false;
        if (s[i] == 'R' && i%2 == 1) flag = false;
    }
    if (flag) puts("Yes"); else puts("No");
    return 0;
}

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

#define MAX_B 100001

int main() {
	ll n;
	vector<ll> v;
	ll now = 1;
	ll count = 0;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		v.push_back(a);
	}

	REP(i, MAX_B) {
		if (now == 2) {
			cout << count << endl;
			return 0;
		}

		now = v[now - 1];
		count++;
	}

	cout << -1 << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,ans;
pair<int,int> a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i].first);
		a[i].second=i;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) if((i-a[i].second)&1) ans++;
	printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAXN = 103;

int w, h;
int board[MAXN][MAXN];
bool vis[MAXN][MAXN];

vector<pair<int, int>> dir = {{0, 1}, {1, 0}};

int dp[MAXN][MAXN];

void dfs(int x, int y) {
  vis[x][y] = true;
  for (auto d : dir) {
    int newX = x + d.first;
    int newY = y + d.second;

    if (newX > h || newY > w) {
      continue;
    }

    if (!vis[newX][newY] && board[newX][newY] == 1) {
      dfs(newX, newY);
    }
  }
}

int main() {
  cin >> h >> w;
  for (int i = 1; i <= h; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < w; ++j) {
      board[i][j + 1] = (s[j] == '.' ? 0 : 1);
    }
  }
  for (int i = 0; i <= h + 1; ++i) {
    for (int j = 0; j <= w + 1; ++j) {
      dp[i][j] = 1 << 30;
    }
  }

  dp[h + 1][w] = 0;
  dp[h][w + 1] = 0;
  for (int i = h; i >= 1; --i) {
    for (int j = w; j >= 1; --j) {
      if (board[i][j] == 0) {
        dp[i][j] = min(dp[i + 1][j], dp[i][j + 1]);
        continue;
      }

      for (int i2 = i; i2 <= h; ++i2) {
        for (int j2 = j; j2 <= w; ++j2) {
          vis[i2][j2] = false;
        }
      }

      dfs(i, j);

      for (int i2 = i; i2 <= h; ++i2) {
        for (int j2 = j; j2 <= w; ++j2) {
          if (vis[i2][j2] == true) {
            // cout << i << " " << j << " :: " << i2 << " " << j2 << endl;
            if (board[i2][j2] == 0) {
              dp[i][j] = min(dp[i][j], dp[i2][j2]);
            } else {
              dp[i][j] = min(dp[i][j], dp[i2][j2 + 1] + 1);
              dp[i][j] = min(dp[i][j], dp[i2 + 1][j2] + 1);
            }
          }
        }
      }
    }
  }
  // for (int i = 1; i <= w; ++i) {
  //   for (int j = 1; j <= h; ++j) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[1][1] << endl;
}


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

int main() {
  int k;
  while(cin >> k, k) {
    if(k  == 2) {
      int l;
      cin >> l;
      cout << l << endl;
      continue;
    }
    int ns = k * (k - 1) / 2;
    int total = 0;
    for(int i = 0; i < ns; ++i) {
      int l;
      cin >> l;
      total += l;
    }
    cout << total / (k - 1) << endl;
  }
  return 0;
}

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

int main(){
  int k,co,i,n;
  cin >> n >> k;
  double ans,cocal;
  ans=0;
  cocal=1;
  for(i=1;i<=n;++i){
    cocal=1;
    if(i>=k){
      ans=ans+(1.0/n);
    }else{
      co=i;
      while(co<k){
        co=co*2;
        cocal=cocal*2;
      }
      ans=ans+(double)((1.0/n)*(1.0/cocal));
    }
  }
  printf("%.10f",ans);
  return 0;
}


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

int main(){
    int i,n,a,min= 1000000,max=-1000000;
    long sum=0;
    cin >> n;
    for (i=0; i<=n;i++)
{
    sum+=a;
    cin>> a;
    if (max<a){
        max=a;
    }
    if (min>a) {
        min=a;
    }
   
}
cout << min<< " "<< max << " "<< sum << endl;
	
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e6 + 5;
int p = 1e9 + 7;

int n,k;
int a[N],f[N];

bool check(int x)
{
	int cur=0;
	for(int i=1;i<=n;i++)
	{
		int div=x/f[i];
		if(div<a[i])
			cur+=a[i]-div;
	}
	return cur<=k;
}

int binsearch(int lo,int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		if(check(mid))
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}

int32_t main()
{	
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>f[i];
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,greater<int>());
	cout<<binsearch(0,1e12);	
	return 0;
}

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

public class Main{

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
            String s1 = in.next();
            String s2 = in.next();
            boolean check = false;
            int n = s1.length();
        for(int i =0 ; i< n; i++){
            if(s1.equals(s2)){
                check = true;
                break;
            }
            s1 = s1.charAt(n-1) + s1.substring(0 , n-1);
            // System.out.println(s1);
        }

            
         if(check)  System.out.println("Yes");
         else System.out.println("No");
    }
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll INF = 1001001001001001001;

int N;
ll A[20][20], B[1<<16];
ll dp[1<<16];

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            std::cin >> A[i][j];
        }
    }

    for(int i=0;i<(1<<N);++i){
        for(int j=0;j<N;++j){
            unless(i >> j & 1){
                continue;
            }

            for(int k=j+1;k<N;++k){
                unless(i >> k & 1){
                    continue;
                }

                B[i] += A[j][k];
            }
        }
    }

    std::fill(dp, dp+(1<<N), -INF);
    dp[0] = 0;

    for(int i=1;i<(1<<N);++i){
        for(int j=i;j>0;j=(j-1)&i){
            dp[i] = std::max(dp[i], B[j] + dp[i ^ j]);
        }
    }

    ll res = dp[(1<<N)-1];
    std::cout << res << std::endl;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int answer = 0;
    for (int a = 1; a <= k; a++) {
      for (int b = a; b <= k; b++) {
        for (int c = b; c <= k; c++) {
          int gcd = gcd(a, gcd(b, c));
          if (a == b && b == c) {
            answer += gcd;
          } else if (a == b || a == c || b == c) {
            answer += 3 * gcd;
          } else {
            answer += 6 * gcd;
          }
        }
      }
    }
    System.out.println(answer);
  }

  static int gcd(int a, int b) {
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);
  }
}


Measured memory_bytes: 35672
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(void){
	int n; cin>>n;
	string s, t;
	cin>>s>>t;

	for(int i=n;i<=n*2-1;i++) {
		string S,T;
		S = s.substr(i-n, 2*n -i);
		T = t.substr(0, 2*n - i);
		if(S == T) {
			cout<< i <<endl;
			return 0;
		}
	}

	cout<< 2*n <<endl;

	return 0;
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
jobs = [[] for i in range(M)]

for i in range(N):
  a, b = map(int, input().split())
  if a > M:
    continue
  jobs[M-a].append(b)
sum_salary = 0
h=[]
for i in range(M-1, -1, -1):
  for b in jobs[i]:
    heapq.heappush(h,-b)
  if(len(h)!=0):
    a = -heapq.heappop(h)
    sum_salary += a
print(sum_salary)

Measured memory_bytes: 18392
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 

using namespace std;

int main() {
	int i, j;
	int len;
	string str;

	cin >> str;

	cout << str.substr(0, str.length() - 8);





	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;


	
	double ex(double a,string b){
		if(b=="JPY")
			return a;
		else
			return a*380000.0;
	}
int main()
{
	string j,b,input;
	double ans=0;
	double in;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>in>>input;
		ans+=ex(in,input);
	}
	cout<<setprecision(20)<<ans<<endl;
	return 0;

}
	

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

long long dp[100005];

int main()
{
	int n, k;
	cin >> n >> k;
	
	int hei[n];
	for (int i = 0; i < n; i++) {
		cin >> hei[i];
	}
	
	dp[0] = 0;
	fill(dp+1, dp+100005, LLONG_MAX);
	//cout << dp[0] << ' ' << dp[1] << "\n";
	
	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if (i-j>=0) {
				dp[i] = min(dp[i], dp[i-j]+abs(hei[i]-hei[i-j]));
			}
		}
	}
	
	cout << dp[n-1] << "\n"; 
}

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

class card{
	final private String str;
	final private int number;
	final private int id;
	
	//コンストラクタの生成
	card(String str, int id){
		this.str  =str;
		number = Integer.parseInt(str.substring(2));
		this.id = id;
	}
	
	final int getId() {
		return id;
	}
	
	final int getNumber() {
		return number;
	}
	
	@Override
	public final String toString() {
		return str;
	}
}


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		final int n = Integer.parseInt(br.readLine());
        final card[] A = new card[n];
        for(int i = 0; i<n; i++) {
        	A[i] = new card(br.readLine(), i);
        }
        quickSort(A, 0, n-1);
        sb.append(isStable(A) ? "Stable\n" : "Not stable\n");
        for(int i = 0; i<n; i++)
            sb.append(A[i]).append('\n');
        System.out.print(sb);
	}
	
	private static void quickSort(card[] A, int p, int r) {
		if(p < r) {
			final int q = partition(A, p, r);
			quickSort(A, p, q - 1);
			quickSort(A, q + 1, r);
		}
	}
	
	public static int partition(card[] A, int p, int r) {
		final card x = A[r];
		int i = p;
		card t;
		for(int j = p; j<r; j++){
            if(A[j].getNumber()<=x.getNumber()){
                t = A[i];
                A[i] = A[j];
                A[j] = t;
                i++;
            }
        }
        A[r] = A[i];
        A[i] = x;
        return i;
	}
	
	private static boolean isStable(card[] A) {
		for(int i = 1, n = A.length; i<n; i++){
            if(A[i-1].getNumber()==A[i].getNumber()&&A[i-1].getId()>A[i].getId()) return false;
        }
        return true;
	}
}



Measured memory_bytes: 48872
#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)

int main()
{
	int n;
	double k;
	cin >> n >> k;
	int arr[n];
	REP(i,0,n)cin >> arr[i];
	double ans = (n-1)/(k-1);
	ans = ceil(ans);
	cout << ans;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int i;
  char s[200005];
  scanf("%s",&s);
  for(i=0;s[i]!=0;i++){
    if(s[i]=='?'){
      s[i]='D';
    }
  }
  printf("%s",&s);
  return(0);
}

Measured memory_bytes: 1928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String[] word = new String[105];
		int[] page = new int[105];
		int i = 0;
		while(stdIn.hasNext()){
			word[i] = stdIn.next();
			page[i++] = stdIn.nextInt();
		}
		int end = i;
		for(i=0;i<end;i++){
			int min = i;
			for(int j=i+1;j<end;j++){
				if(word[min].compareTo(word[j])==0&&page[min]>page[j]){
					min = j;
				}
				if(word[min].compareTo(word[j])>0){
					min = j;
				}
			}
			String tmp = word[i];
			word[i] = word[min];
			word[min] = tmp;
			int tmp2 = page[i];
			page[i] = page[min];
			page[min] = tmp2;
		}
		for(i=0;i<end;i++){
			if(i!=0&&word[i-1].compareTo(word[i])==0){
				System.out.print(" "+page[i]);
				continue;
			}
			else if(i!=0){
				System.out.println();
			}
			System.out.println(word[i]);
			System.out.print(page[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

//タロー→ハナァコォ

const int NONE = -1;

int main(void)
{
	while(1)
	{
		int n;
		vector<int> card[2];
		cin >> n;
		if(n==0)
			return 0;

		int field=NONE;//今場に出ているカード
		int turn=0;//0:太郎,1:花子;

		bool a[301]={};
		for(int i=0;i<n;++i)
		{
			int t;
			cin >> t;
			card[0].push_back(t);
			a[t] = true;
		}

		for(int i=1;i<=2*n;++i)
		{
			if(a[i] == false)
				card[1].push_back(i);
		}

		sort(card[0].begin(),card[0].end());
		sort(card[1].begin(),card[1].end());

		while(1)
		{
			if(card[0].empty() || card[1].empty())
				break;
			if(field==NONE)
			{
				field = card[turn][0];
				card[turn].erase(card[turn].begin());
			}
			else
			{
				bool outFlag = false;
				for(int i=0;i<card[turn].size();++i)
				{
					if(field < card[turn][i])//出せるカードがある
					{
						field = card[turn][i];
						outFlag = true;
						card[turn].erase(card[turn].begin()+i);
						break;
					}
				}
				if(outFlag == false)
				{
					field = NONE;
				}
			}
			if(turn==0) turn=1;
			else if(turn==1) turn=0;
		}
		int tsum=0;
		int hsum=0;
		for(int i=0;i<card[0].size();++i)
		{
			hsum += card[0][i];
		}
		for(int j=0;j<card[1].size();++j)
		{
			tsum += card[1][j];
		}
		cout << card[1].size() << endl;
		cout << card[0].size() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void)
{
	int n;
	cin >> n;
	cout << n / 3 << endl;

	return 0;
}



Measured memory_bytes: 256
import numpy as np
from math import log
N=int(input())

L=[1]
for i in range(1,N):
    if 6**i<=N:
        L.append(6**i)
    else:
        break
for i in range(1,N):
    if 9**i<=N:
        L.append(9**i)
    else:
        break
L=np.array(L)
dp=np.ones((N+1))*100000
dp[0]=0
dp[1]=1
for i in range(2,N+1):
    dp[i]=(dp[i-L]+1).min()

print(int(dp[N]))

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define mod 1000000007
#define x first
#define y second
#define codec ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef vector<int> vi;
typedef vector<long long int> vl;
#define deb cout<<"Heelo"<<endl;
typedef pair<int, int> pi;
int main()
{
    ll n;
    cin>>n;
    ll sum=0; 
    if(n%2==0){
    rep(i,1,n/2){
        sum+=(n-1)/i;
    }
    cout<<sum+n/2;}
    else{
       rep(i,1,n/2+1){
        sum+=(n-1)/i;
    }
    cout<<sum+n/2; 
    }

}

Measured memory_bytes: 3612
#include <iostream>
typedef long long ll;
using namespace std;

int main(void)
{
  ll a, b, n;
  cin >> a >> b >> n;

  if (n>=b){
    cout << a*(b-1)/b << endl;
  }else {
    cout << a*n/b << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    int edge[3] = {0};
    cin >>edge[0]>>edge[1]>>edge[2];
    sort(edge,edge+3);
    if(edge[0]*edge[0]+edge[1]*edge[1] == edge[2]*edge[2]){cout <<"YES"<<endl;}
    else{cout <<"NO"<<endl;}
  }
  return 0;
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> A, B, C;
	for(int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		A.push_back(a - 1);
	}
	for(int i = 0; i < N; ++i) {
		int b;
		cin >> b;
		B.push_back(b);
	}
	for(int i = 0; i < N - 1; ++i) {
		int c;
		cin >> c;
		C.push_back(c);
	}
	int ans = 0;
	for(int i = 0; i < N; ++i) {
		ans += B[A[i]];
		if(i < N - 1) {
			if(A[i] + 1 == A[i + 1]) {
				ans += C[A[i]];
			}
		}
	}
	cout << ans << '\n';
	return 0;
}



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

int main()
{
    int N, A, mod;
    cin >> N >> A;

    mod = N % 500;

    if (A >= mod)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
arr = gets.split(' ').map(&:to_i)
count = 0

n.times do |sorted_i|
  min_i = sorted_i
  ((sorted_i)..(n - 1)).each do |j|
    if arr[j] < arr[min_i]
      min_i = j
    end
  end
  if sorted_i != min_i
    count += 1
    tmp = arr[sorted_i]
    arr[sorted_i] = arr[min_i]
    arr[min_i] = tmp
  end
end

puts arr.join(' ')
puts count



Measured memory_bytes: 6876
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string.h>

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);
    int ans = 0;
    if (A >= B)
    {
        ans += A;
        --A;
    }
    else
    {
        ans += B;
        --B;
    }
    ans += std::max(A, B);
    printf("%d\n", ans);
    return 0;
}

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

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

const int maxn = 2e5 + 5;
int n;
vector<int> adj[maxn];
int vis[maxn];

int dfs(int node) {
    vis[node] = 1;
    int res = 1; 
    for(int nei : adj[node]) {
        if(vis[nei]) continue;
        res += dfs(nei);
    }
    return res;
}

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

    int m;
    cin >> n >> m;
    for(int i=0; i<m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u-1].push_back(v-1);
        adj[v-1].push_back(u-1);
    }
    for(int i=0; i<n; i++) vis[i] = 0;

    int res = 0;
    for(int i=0; i<n; i++) {
        if(!vis[i]) res = max(res, dfs(i));
    }
    cout << res << endl;


    return 0;
}

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, a, b;
    cin >> a >> b >> n;
    ll x=min(n, b-1);
    cout << (x*a)/b-a*(x/b);

    return 0;
}


Measured memory_bytes: 3612
n, m, k = map(int, input().split())

mod = 998244353
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]
for i in range(2, n+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod%i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

def comb(n, r):
    if r<0 or r>n:
        return 0
    return g1[n] * g2[r] * g2[n-r] % mod

ans = 0
for i in range(k+1):
    ans += comb(n-1, i)*m*pow(m-1,n-i-1, mod)
    ans %= mod
print(ans)

Measured memory_bytes: 112344
#####segfunc######                                                              
def segfunc(x,y):
    return max(x,y)

def init(init_val):
    #set_val                                                                    
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built                                                                      
    for i in range(num-2,-1,-1):
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
    
def update(k,x):
    k+=num-1
    seg[k]=x
    while k+1:
        k=(k-1)//2
        seg[k]=segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p+=num-1
    q+=num-2
    res=ide_ele
    while q-p>1:
        if p&1==0:
            res=segfunc(res,seg[p])
        if q&1==1:
            res=segfunc(res,seg[q])
            q-=1
        p=p//2
        q=(q-1)//2
    if p==q:
        res=segfunc(res,seg[p])
    else:
        res=segfunc(segfunc(res,seg[p]),seg[q])
    return res

ide_ele=0
n=int(input())
num=2**(n-1).bit_length()
seg=[ide_ele]*2*num
h=list(map(int,input().split()))
a=list(map(int,input().split()))
dp=[0]*n
init(dp)
ans=0
for i in range(n):
    tmp=query(0,h[i])
    update(h[i]-1,tmp+a[i])

ans=query(0,n)
print(ans)


Measured memory_bytes: 109692
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const ll INF = 10010010010010;

int main() {
	ll N, K;
	cin >> N >> K;

	vector <ll> A(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}

	ll l = 0;
	ll r = INF;
	while(l + 1 < r) {
		ll mid = (l + r) / 2;

		ll sum = 0;
		for (int ii = 0; ii < N; ++ii){
			sum += (A[ii] + mid-1) / mid - 1;
		}

		bool ok = (sum <= K) ? true : false;

		if (ok){
			r = mid;
		} else {
			l = mid;
		}
	}

	cout << r << "\n";

	return 0;
}


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

using namespace std;
using lint = std::int_fast64_t;

lint N;

int f(lint x) {
  if (x > N) return 0;

  auto check = [](lint x) {
    map<int, int> cnt;
    while (x > 0) {
      cnt[x % 10]++;
      x /= 10;
    }
    return (int)cnt.size() == 3;
  };

  int res = 0;
  if (check(x)) res += 1;

  res += f(10 * x + 7);
  res += f(10 * x + 5);
  res += f(10 * x + 3);

  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  cout << f(0) << '\n';
  return 0;
}


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

ll solve() {
    ll N, X, T;
    cin >> N >> X >> T;
    ll ans = (N+X-1)/X*T;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// nCr mod を計算する O(n)
const int MAX_N = 1000010;
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();
    for(int i=1;i<=k;i++){
        cout<<(COM(n-k+1,i)*COM(k-1,i-1))%MOD<<endl;
    }

}




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

int main(){
  // 入力
  int A[3][3];
  int N;
  vector<int> b;
  cin >> A[0][0] >> A[0][1] >> A[0][2];
  cin >> A[1][0] >> A[1][1] >> A[1][2];
  cin >> A[2][0] >> A[2][1] >> A[2][2];
  cin >> N;
  for (int i=0; i<N; i++) {
    int b_tmp;
    cin >> b_tmp;
    b.push_back(b_tmp);
  }

  bool maru[3][3] = {};
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      for (int k=0; k<N; k++) {
        if (A[i][j] == b[k]) {
          maru[i][j] = true;
        }
      }
    }
  }

  string result = "No";
  if (   ( maru[0][0] == true && maru[0][1] == true && maru[0][2] == true )
      || ( maru[1][0] == true && maru[1][1] == true && maru[1][2] == true )
      || ( maru[2][0] == true && maru[2][1] == true && maru[2][2] == true )
      || ( maru[0][0] == true && maru[1][0] == true && maru[2][0] == true )
      || ( maru[0][1] == true && maru[1][1] == true && maru[2][1] == true )
      || ( maru[0][2] == true && maru[1][2] == true && maru[2][2] == true )
      || ( maru[0][0] == true && maru[1][1] == true && maru[2][2] == true )
      || ( maru[2][0] == true && maru[1][1] == true && maru[0][2] == true ) ){
    result = "Yes";
  }

  cout << result << endl;

  return 0;
}

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

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

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,i,ans,p,max,sum;
    ans=0;
    max=0;
    sum=0;
    cin >> N ;
    for(i=0;i<N;i++){
        cin >> p;
        sum+=p;
        if(max<p) max=p;
    }
    ans=sum-max;
    max=max/2;
    ans+=max;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
int n;
int a[13];
int f[13][2];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		if((a[i]-1)%2==0||a[i]-1==0){
			f[i][1]+=f[i-1][0]+f[i-1][1];
		}else{
			f[i][1]+=f[i-1][1];
			f[i][0]+=f[i-1][0];
		}
		if((a[i])%2==0){
			f[i][1]+=f[i-1][0]+f[i-1][1];
		}else{
			f[i][1]+=f[i-1][1];
			f[i][0]+=f[i-1][0];
		}
		if((a[i]+1)%2==0){
			f[i][1]+=f[i-1][0]+f[i-1][1];
		}else{
			f[i][1]+=f[i-1][1];
			f[i][0]+=f[i-1][0];
		}
	}
	cout<<f[n][1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
const int P = 1000000007;
int N;
ll X[Nmax];

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

	vector<ll> stack;
	ll ans = 1;
	for(int i=0; i<N; i++){
		if(X[i] < 2*stack.size()+1){
			ans *= stack.size()+1;
			ans %= P;
		}
		else{
			stack.push_back(X[i]);
		}
	}

	for(int i=0; i<stack.size(); i++){
		ans *= i+1;
		ans %= P;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2168