akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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 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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i, n) {
        if(a[i] == b[i]) {
            if(b[i] == c[i]) {
                if(c[i] == a[i]) {
                    continue;
                } else {
                    continue;
                }
            } else {
                if(c[i] == a[i]) {
                    continue;
                } else {
                    ans += 1;
                }
            }
        } else {
            if(b[i] == c[i]) {
                if(c[i] == a[i]) {
                    continue;
                } else {
                    ans += 1;
                }
            } else {
                if(c[i] == a[i]) {
                    ans += 1;
                } else {
                    ans += 2;
                }
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main() {
  stack<int> S1;
  stack<pair<int , int > > S2;
  char ch;
  int sum = 0;
  for(int i=0;cin >> ch;i++) {
    if(ch == '\\') S1.push(i);
    else if(ch == '/' && S1.size() >0) {
      int j=S1.top(); S1.pop();
      sum += i-j;
      int a=i-j;
      while(S2.size() > 0 && S2.top().first > j) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }

  vector<int> ans;
  while(S2.size() > 0) {
    ans.push_back(S2.top().second); S2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout<<sum<<endl;
  cout<<ans.size();
  for(int i = 0;i<ans.size();i++){
    cout<<" ";
    cout << ans[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>
#include <math.h>

struct Point{ double x, y;};

void koch(int n, Point a, Point b){
  if (n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



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

int main() {
	string S;
	cin >> S;
	for (int i = 0;i<S.size();++i) {
		if (',' == S[i]) {
			S[i] = ' ';
		}
	}
	cout <<S <<endl;
	return 0;
}

Measured memory_bytes: 3632
/*-----------Author: Araz Jabrayilov---------*/
/*------------@araz17----(~~)#5371-----------*/

#include <bits/stdc++.h>

#define ll long long
#define endl '\n'

using namespace std;

//int a[105]];


int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int x = 0;
    int y = 0;
    int z = 0;

    cin >> x >> y >> z;

    cout << z  << " " << x << " " << y;


    return 0;
}


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


int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i=0; i<N; i++) cin >> a.at(i);
    sort(a.begin(), a.end());
    
    int i = 0;
    while (x >= a.at(0) && i < N) {
        x -= a.at(i);
        i++;
    }
    if (x < 0 || (x > 0 && i == N))  {
        i--;
    }
    
    cout << i << endl;
    
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1
#define MOD(x, m) ((x) % (m) + (m)) % (m)

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

template <typename T>
void join(vector<T>& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }
    ll k = n / 2;

    const ll impos = -9e18;
    map<pair<ll, ll>, ll> dp;
    function<ll(ll, ll)> helper = [&](ll i, ll k) {
        auto it = dp.find({i, k});
        if (it != dp.end())
            return it->second;
        if (k == 0) {
            dp[{i, k}] = 0;
            return 0ll;
        }
        if (i >= n) {
            dp[{i, k}] = impos;
            return impos;
        }
        if ((n-i) % 2 == 0) {
            if (k > (n-i)/2) {
                dp[{i, k}] = impos;
                return impos;
            }
        } else {
            if (k > (n-i)/2+1) {
                dp[{i, k}] = impos;
                return impos;
            }
        }
        ll res1 = helper(i+1, k);
        ll res2 = helper(i+2, k-1);
        if (res2 != impos) {
            res2+=a[i];
        }

        ll res = max(res1, res2);
        dp[{i, k}] = res;
        return res;
    };

    ll res = helper(0, k);
    cout << res << "\n";
}

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

    return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  VI a(3);
  REP(i,3){
    cin >> a.at(i);
  }
  SORT(a);
  int x = a.at(0)+a.at(1)-a.at(2);
  
  if(x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n; cin >> n;
    string s; cin >> s;

    int count = 0;
    REP(i, n) {
        if (s[i] != s[i + 1]) count++;
    }
    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 512
class itp1_3b:
    def out(self,i,x):
        print "Case "+str(i)+": "+str(x)
if __name__=="__main__":
    run=itp1_3b()
    i=1
    while(True):
        
        x=input()
        if x==0:
            break
        run.out(i,x)
        i+=1

Measured memory_bytes: 4212
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int dir[2][8] = {{-1, -1, -1, 0, 1, 1, 1, 0}, {-1, 0, 1, -1, -1, 0, 1, 1}};

void dfs(int i, int j, vector<vector<int>>& used, vector<vector<int>>& color){
  used[i][j] = 1;
  for(int d = 0; d < 8; d++){
    if(i + dir[0][d] >= 0 && i + dir[0][d] < used.size() && j + dir[1][d] >= 0 && j + dir[1][d] < used[0].size()){
      if(!used[i+dir[0][d]][j+dir[1][d]] && color[i+dir[0][d]][j+dir[1][d]]){
        dfs(i + dir[0][d], j + dir[1][d], used, color);
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int w, h;
  while(cin >> w >> h && w){
    vector<vector<int> > used(h, vector<int>(w, 0));
    vector<vector<int> > color(h, vector<int>(w, 0));
    int ans = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        cin >> color[i][j];
      }
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(!used[i][j] && color[i][j]) ans++, dfs(i, j, used, color);
      }
    }
    cout << ans << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

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

	int n, m;
	string id;
	cin >> n >> id >> m;

	vector<int> a(m);
	for(int i = 0; i < m; ++i)
		cin >> a[i];

	vector<int> dp(10, 0);
	dp[0] = 1;
	for(int i = 0; i < n; ++i) {
		vector<int> tmp(10, 0);

		int c = (i & 1 ? 2 : 1);
		if(id[n - i - 1] == '*') {
			for(int k = 0; k < m; ++k) {
				int num = c * a[k];
				num = num % 10 + num / 10;
				for(int j = 0; j < 10; ++j)
					tmp[(j + num) % 10] += dp[j];
			}
		}

		else {
			int num = c * (id[n - i - 1] - '0');
			num = num % 10 + num / 10;
			for(int j = 0; j < 10; ++j)
				tmp[(j + num) % 10] += dp[j];
		}

		dp.swap(tmp);
	}

	cout << dp[0] << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n;
    cin >> n;
    vector<double> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    double d = 0.0;
    for(int i = 0; i < n; i++){
        d += 1.0/a[i];
    }
    printf("%.10f\n",1.0/d);

    return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int F[maxx << 1];
void update(int i, int val) {
    for (; i < (maxx << 1); i |= i + 1) {
        F[i] += val;
    }
}
int getf(int i) {
    int res = 0;
    for (; i >= 0; i &= i + 1, i--) {
        res += F[i];
    }
    return res;
}

int n, arr[maxx], brr[maxx];
const int N = 100001;

long long get(int x) {
    vector <int> pref(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        if (brr[i] < x) {
            arr[i] = -1;
        } else if (brr[i] == x) {
            arr[i] = 1;
        } else {
            arr[i] = 1;
        }
        pref[i] = pref[i - 1] + arr[i];
    }
    for (int i = 1; i <= n; i++) pref[i] += N;
    long long res = 0;
    update(N, 1);
    for (int i = 1; i <= n; i++) {
        res += getf(maxx * 2 - 1) - getf(pref[i]);
        update(pref[i], 1);
    }
    return res;
}

int main() {
    //freopen("262144.in","r",stdin);
    //freopen("262144.out","w",stdout);
    cin >> n;
    vector <int> v;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i]; brr[i] = arr[i];
        v.pb(arr[i]);
    }/*
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            vector <int> p;
            for (int k = i; k <= j; k++) {
                p.pb(arr[k]);
            }
            sort(all(p));
            int md = p[p.size() / 2];
            if (md < 5) cnt++;
        }
    }
    cout << cnt << endl;
    cout << get(5) << " " << get(8) << endl;
    return 0;*/
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    long long total = 1LL * n * (n + 1) / 2LL;
    int l = 0, r = v.size() - 1, best;
    while (r - l >= 0) {
        int mid = (l + r) >> 1, x = v[mid];
        long long t = get(x);
        if (t > total / 2 + 1) {
            r = mid - 1;
        } else {
            l = mid + 1, best = mid;
        }
        memset(F, 0, sizeof(F));
    }
    cout << v[best] << endl;
    return 0;
}


Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin>>n;
  string str=to_string(n);
  int divi=0;
  for(int i=0;i<(int)str.length();i++)
  {
    divi+=(int)(str[i]-'0');
  }
  if(n%divi==0)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  
  
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  string s, t; cin >> s >> t;
  vvl s_al(26);
  vvl t_al(26);
  rep(i,s.length()) {
    s_al[s[i] - 'a'].pb(i);
  }
  rep(i,t.length()) {
    t_al[t[i] - 'a'].pb(i);
  }
  bool ok = true;
  rep(i,26) {
    if (!t_al[i].empty() && s_al[i].empty()) {
      ok = false;
    }
  }
  if (!ok) {
    cout << "-1" << endl;
    return 0;
  }

  ll ans = 0, t_id = 0, pos = -1;
  vl used_nums(26, 0);
  while (t_id < t.length()) {
    int moji = t[t_id] - 'a';
    // cout << "t["<<t_id<<"] = " << t[t_id] << endl;
    int next_pos_id = upper_bound(all(s_al[moji]),pos) - s_al[moji].begin();
    if (next_pos_id == s_al[moji].size() ||
        next_pos_id < used_nums[moji]) {
      ans += s.length() - pos - 1;
      pos = -1;
      used_nums.assign(26,0);
    } else {
      ans += s_al[moji][next_pos_id] - pos;
      pos = s_al[moji][next_pos_id];
      used_nums[moji] = next_pos_id;
      t_id++;
    }
    // cout << "  pos = " << pos << endl;
    // cout << "  ans = " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2872
h,w,k=[int(j) for j in input().split()]
s=[list(map(int,list(input()))) for i in range(h)]
import itertools
s=tuple(itertools.chain(*zip(*s)))
ans=10**18
for i in range(1<<(h-1)):
    dp=list(s)
    for j in range(h-1):
        if i&(1<<j):
            for n in range(0,h*w,h):
                dp[n+j+1]+=dp[n+j]
    tmp=h-1-bin(i).count("1")
    b=False
    for n in range(0,h*w,h):
        if any(dp[n+j]>k for j in range(h)):
            tmp=10**18
            break
        if n+h==h*w:
            ans=min(ans,tmp)
            tmp=10**18
            break
        if any(dp[n+j]+dp[n+j+h]>k for j in range(h)):
            tmp+=1
            continue
        for j in range(h):
            dp[n+j+h]+=dp[n+j]
    ans=min(ans,tmp)
print(ans)

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

int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> vec(n);
  vector<int64_t> original(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    original.at(i) = vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    if (original.at(i) == vec.at(0)) cout << vec.at(1) << endl;
    else cout << vec.at(0) << endl;
  }
  
  
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[200000];
int B[200000];

int main()
{
	int N;

	cin >> N;
	rep(i, N) {
		cin >> A[i];
		B[i] = A[i];
	}

	sort(B, B + N, greater<int>());

	rep(i, N) {
		if (A[i] == B[0]) cout << B[1] << endl;
		else cout << B[0] << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    String[] abc = new String[]{a, b, c};

    int t = 0;
    for (; ; ) {
      String e = abc[t];
      if (e.length() == 0) {
        break;
      }
      int next = abc[t].charAt(0) - 'a';
      abc[t] = abc[t].substring(1);
      t = next;
    }
    System.out.println(new String[]{"A", "B", "C"}[t]);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 9684
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n;
	vector<int>list;

	cin >> n;

	int maxn = 0;

	//list.push_back(-1);
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
		maxn = max(maxn, num);
	}

	sort(list.begin(), list.end());
	int cnt = 0, naka = n / 2 - 1;

	int num1 = list[naka];
	int num2 = list[naka + 1];

	cout << abs(num2 - num1) << endl;

	return 0;
}

Measured memory_bytes: 892
# -*- coding: utf-8 -*-

import sys

n = int(input())
a = []
for i in range(0,n):
	a.append(0)
for i in range(0,n):
	a[i]=int(input())

first=a[0]
second=a[1]
if first < second:
	tmp = first
	first = second
	second = tmp

for j in range(2,n):
	if(a[j]>first):
		second = first
		first = a[j]
	elif(a[j]>=second):
		second = a[j]

for i in range(0,n):
	if(a[i]==first):
		print(second)
	else:
		print(first)


Measured memory_bytes: 12528
#include <iostream>
#include <algorithm>

using namespace std;

class Solver {
public:
	static void solve() {
		int w;
		cin >> w;
		int now = 1;
		int cnt = 1;
		int sum = 1;
		while (sum < w) {
			now *= 3;
			cnt++;
			sum += now;
		}

		string s = "+";
		w -= now;
		now /= 3;
		for (int i = cnt; i > 1; i--) {
			if (abs(abs(w)-now)<abs(w)) {
				if (w < 0) {
					s += "-";
					w += now;
				}
				else {
					s += "+";
					w -= now;
				}
			}
			else {
				s += "0";
			}
			now /= 3;
		}

		cout << s << endl;
	}
};

int main() {
	Solver::solve();
}


Measured memory_bytes: 3148
#include<cstdio>
#define ll long long
using namespace std;
const int N=1e5+5;
int n,l=0,r=1000000001,A[N],C[N],T[N];
ll Merge(int l,int r){
	if(l==r)return 0;
	int mid=(l+r)/2;
	int i=l,j=mid+1,k=l;
	ll ret=Merge(l,mid)+Merge(mid+1,r);
	while(i<=mid&&j<=r){
		if(C[i]<=C[j])T[k++]=C[i++];
		else ret+=i-l,T[k++]=C[j++];
	}
	while(i<=mid)T[k++]=C[i++];
	while(j<=r)ret+=i-l,T[k++]=C[j++];
	for(int x=l;x<=r;++x)C[x]=T[x];
	return ret;
}
bool Check(int x){
	for(int i=1;i<=n;++i)C[i]=(A[i]>=x?1:-1)+C[i-1];
	return Merge(0,n)*2>=1ll*n*(n+1)/2;
}
int main(){
	scanf("%d",&n);
//	for(int i=1;i<=n;++i)scanf("%d",&C[i]);
//	printf("%d\n",Merge(1,n));
	for(int i=1;i<=n;++i)scanf("%d",&A[i]);
	while(l+1<r){
		int mid=(l+r)/2;
		if(Check(mid))l=mid;
		else r=mid;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 1280
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int main(){
	int q;
	cin >> q;
	while(q--){
		int n, cnt = 0;
		cin >> n;
		while(n > 9){
			char buf[20];
			sprintf(buf, "%d", n);
			string s = buf;
			n = -1;
			rep(i, s.size() - 1){
				n = max(n, atoi(s.substr(0, i + 1).c_str()) * atoi(s.substr(i + 1).c_str()));
			}
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int n = s.Length;
		long[] answers = new long[n];
    int lMemo = -1;
    int rMemo = -1;
    bool lTrue = true;
    bool rTrue = true;

    for(int i = 0; i < n; i++)
    {
      if(s[i] == 'L')
      {
        if(lMemo == -1)
        {
          lMemo = i;
          answers[i]++;
          lTrue = false;
        }else
        {
          if(lTrue) answers[lMemo]++;
          else answers[lMemo-1]++;
          lTrue = !lTrue;
        }
      }else lMemo = -1;
    }

    for(int i = n-1; i >= 0; i--)
    {
      if(s[i] == 'R')
      {
        if(rMemo == -1)
        {
          rMemo = i;
          answers[i]++;
          rTrue = false;
        }else
        {
          if(rTrue) answers[rMemo]++;
          else answers[rMemo+1]++;
          rTrue = !rTrue;
        }
      }else rMemo = -1;
    }
    
    Console.WriteLine(string.Join(" ", answers));
	}
}

Measured memory_bytes: 13536
#include<iostream>
using namespace std;
signed main(){
  int n,h[100005],dp[100005]={};
  cin >>n;
  for(int i=1;i<=n;i++){
    cin  >> h[i];
  }
  dp[1]=0;
  for(int i=2;i<=n;i++){
    if(i != 2)
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    else
      dp[i]=abs(h[i]-h[i-1])+dp[i-1];
}
	cout << dp[n] <<'\n';

      return(0);
}


Measured memory_bytes: 1024
A, B, C, X = [int(input()) for _ in range (4)]

ans = 0
for i in range(A+1):
    if 500 * i > X:
        break
    for j in range(B+1):
        if 500 * i + 100 * j > X:
            break
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k > X:
                break
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  cin>>a;
  if(a=="SUN")
    cout<<"7";
  else if(a=="MON")
    cout<<"6";
  else if(a=="TUE")
    cout<<"5";
  else if(a=="WED")
    cout<<"4";
  else if(a=="THU")
    cout<<"3";
  else if(a=="FRI")
    cout<<"2";
  else if(a=="SAT")
    cout<<"1";
}

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

int main() {
    string w; cin >> w;
    map<char, int> mp;
    rep(i,w.size()) {
        mp[w[i]]++;
    }
    for (auto x : mp) {
        if (x.second % 2 != 0) {
            cout << "No"<< endl; 
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    if (a == b) ans = c;
    if (b == c) ans = a;
    if (a == c) ans = b;
 
    cout << ans << endl;
    
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

mv_x = tx - sx
mv_y = ty - sy

ans = ''
ans += 'R' * mv_x + 'U' * mv_y
ans += 'L' * mv_x + 'D' * mv_y
ans += 'D' + 'R' * (mv_x+1) + 'U' * (mv_y+1) + 'L'
ans += 'U' + 'L' * (mv_x+1) + 'D' * (mv_y + 1) + 'R'

print(ans)

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

using namespace std;

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a, b, c;
    int tempA, tempB, tempC;
    for(int x = 0; x <n; ++x)
    {
        cin >> tempA >> tempB >> tempC;
        a.push_back(tempA);
        b.push_back(tempB);
        c.push_back(tempC);
    }
    vector<int> prevA (n, INT_MAX), prevB (n, INT_MAX), prevC(n, INT_MAX);
    prevA[0] = a[0];
    prevB[0] = b[0];
    prevC[0] = c[0];
    for(int x = 1; x < n; ++x)
    {
        prevA[x] = max(prevB[x - 1], prevC[x - 1]) + a[x];
        prevB[x] = max(prevA[x - 1], prevC[x - 1]) + b[x];
        prevC[x] = max(prevB[x - 1], prevA[x - 1]) + c[x];
    }
    cout << max(max(prevA[n - 1], prevB[n - 1]), prevC[n - 1]);
    return 0;
}

Measured memory_bytes: 2924
#include <stdio.h>
#define M 1000000
int a[M];

int main(void)
{
    int n, i, j, cnt;

    a[0] = 0; a[1] = 0;
    for(i=2; i<M; i++) a[i] = 1;

    for(i=2; i*i<M; i++) {
        if(a[i]) {
            for(j=2*i; j<M; j+=i) a[j] = 0;
        }
    }

    while(~scanf("%d", &n)) {
        cnt = 0;
        while(n) {
            cnt += a[n--];
        }
        printf("%d\n", cnt);
    }

    return (0);
}

Measured memory_bytes: 4500
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

 void solve() {
   string s;
   cin>>s;
   int f=0;
   rep(i,0,sz(s)) {
	      if(s[i]=='7') f++;
	   }
	   if(f) cout<<"Yes\n";
	   else cout<<"No\n";             
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n;

inline void work() {
    cin >> n;
    int p = 1;
    int q = 1;
    int r = 1;
    for (int i = 0; i < n; ++i) {
        p = (LL)p * 10 % mod;
        q = (LL)q * 9 % mod;
        r = (LL)r * 8 % mod;
    }
    int ans = ((p - q * 2 % mod + r) % mod + mod) % mod;
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vll path;
//***********//
int main() {
	cin >> N >> M;
	string S;
	cin >> S;
	ll now = N;
	vl Ans;
	while (true) {
		for (i = max(z,now-M); i <= now; i++) {
			if (i == now) {
				cout << -1;
				exit(0);
			}
			//debug(i, S[i]);
			if (S[i] == '0') {
				Ans.push_back(now - i);
				now = i;
				break;
			}
		}
		if (now == 0) break;
	}
	reverse(Ans.begin(), Ans.end());
	for (i = 0; i < Ans.size(); i++) {
		co3(Ans[i]);
	}
}

Measured memory_bytes: 4460
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int n, b, c; CI n >> b >> c;
	vector<double> h(n); CI h;

	double tmp = b-h[0]*0.006;
	int ans = 1;
	FOR(i,1,n-1) {
		double tmp2 = b - h[i] * 0.006;
		if (abs(tmp - c) > abs(tmp2-c)) {
			tmp = b - h[i] * 0.006;
			ans = i+1;
		}
	}

	CO ans EN;

	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  queue<int> hundred;
  queue<int> ten;
  queue<int> one;
  bool frag = true;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (N == 3 && s == 1) {
      if (hundred.empty()) {
        hundred.push(c);
        continue;
      }
      if (hundred.front() != c) {
        frag = false;
      }
    }
    else if ((N==3 && s==2) || (N==2 && s==1)) {
      if (ten.empty()) {
        ten.push(c);
        continue;
      }
      if (ten.front() != c) {
        frag = false;
      }
    }
    else if ((N==3 && s==3) || (N==2&&s==2) || (N==1&&s==1)) {
      if (one.empty()) {
        one.push(c);
        continue;
      }
      if (one.front() != c) {
        frag = false;
      }
    }
  }
  if (!frag) {
    cout << -1 << endl;
    return 0;
  }
  
  if (hundred.empty()) {
    if (N == 3) {
      hundred.push(1);
    }
    else {
      hundred.push(0);
    }
  }
  if (ten.empty()) {
    if (N == 2) {
      ten.push(1);
    }
    else {
      ten.push(0);
    }
  }
  if (one.empty()) {
    one.push(0);
  }
  int h = hundred.front();
  int t = ten.front();
  int o = one.front();
  if (N == 1) {
    cout << o << endl;
  }
  else if (N == 2) {
    if (t != 0) {
      cout << t*10 + o << endl;
    }
    else {
      cout << -1 << endl;
    }
  }
  else if (N == 3) {
    if (h != 0) {
      cout << h*100 + t*10 + o << endl;
    }
    else {
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	int ans = INT_MAX;
	for (int i = 0; i < N; i++) {
		cin >> M;
		int cnt = 0;
		while (M % 2 == 0) {
			M /= 2;
			cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def merge(a, left, mid, right):
    x = 0
    l = a[left:mid] + [float("inf")]
    r = a[mid:right] + [float("inf")]
    i = 0
    j = 0
    for k in range(left,right):
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else :
            a[k] = r[j]
            j += 1
        x += 1
    return x

def mergeSort(a, left, right,x):
    if left+1 < right:
        mid = int((left + right)/2)
        mergeSort(a, left, mid,x)
        mergeSort(a, mid, right,x)
        x[0] += merge(a, left, mid, right)

n = int(input())
s = list(map(int,input().split()))
x = [0]
mergeSort(s,0,n,x)
print(*s)
print(x[0])




Measured memory_bytes: 63428
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)






int main(void)
{

	int n, k;

	cin >> n >> k;

	int ans=1;

	for(int i=1;i<=n;i++)
	{
		if (i == 1) ans *= k;
		else ans*= (k - 1);
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
  int n;
  double x1, y1, x2, y2, x3, y3;
  double px, py, r;
  scanf("%d", &n);
  while(n--){
    scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
    px=((y1-y3)*(y1*y1-y2*y2+x1*x1-x2*x2)-(y1-y2)*(y1*y1-y3*y3+x1\
*x1-x3*x3))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
    py=((x1-x3)*(x1*x1-x2*x2+y1*y1-y2*y2)-(x1-x2)*(x1*x1-x3*x3+y1\
*y1-y3*y3))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
    r=sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
  return 0;
}

Measured memory_bytes: 664
#include <iostream>
#include <sstream>
#include <bitset>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++)
  {
    /* code */
    cin >> p[i];
  }
  bool ans = false;

  for (int i = 0; i < N - 1; i++){
    for (int j = i; j < N; j++)
    {
      /* code */
      //iとjを入れ替える
      int data = p[i];
      p[i] = p[j];
      //cout << data;
      p[j] = data;
      //正しい？
      bool unup = false;
      for (int k = 0; k < N-1;k++){
        //cout << p[k];
        if (p[k] > p[k + 1])
          unup = true;
      }
      //cout << unup << endl;
      if (unup == false)
        ans = true;
      //元に戻す
      data = p[j];
      p[j] = p[i];
      p[i] = data;
    }
  }
  bool unup = false;
  for (int k = 0; k < N - 1; k++)
  {
    //cout << p[k];
    if (p[k] > p[k + 1])
      unup = true;
  }
  if (unup == false)
    ans = true;

  if(ans==false)
    cout << "NO";
  else
    cout << "YES";
}

Measured memory_bytes: 256
<?php

class Answer
{
    private $sequence_len;
    private $sequence;

    public function __construct()
    {
        while (1) {
            $line = FGETS(STDIN);
            if ($line == false) {
                break;
            }
            $line = trim($line);
            $lines[] = $line;
        }
        
        $this->sequence_len = $lines[0];
        $this->sequence = explode(' ', $lines[1]);
    }

    public function selectionSort()
    {
        $seq = $this->sequence;
        $count = 0;
        for ($i = 0; $i < $this->sequence_len; $i++) {
            $minj = $i;
            for ($j = $i; $j < $this->sequence_len; $j++) {
                if ($seq[$j] < $seq[$minj]) {
                    $minj = $j;
                }
            }
            if ($i != $minj) {
                list($seq[$i], $seq[$minj]) = array($seq[$minj], $seq[$i]);
                $count++;
            }
        }
        echo implode(' ', $seq), PHP_EOL;
        echo $count, PHP_EOL;
    }
}
$answer = new Answer;
$answer -> selectionSort();


Measured memory_bytes: 9412
#b
#from itertools import accumulate
n, k  = [int(i) for i in input().split()]
a     = [int(i) for i in input().split()]

plus,minus = [0],[0] #initialize for the beginning
plus_accumulate  = 0
minus_accumulate = 0

for v in a:
    if v>=0:
        plus_accumulate += v
    else:
        minus_accumulate += abs(v) #-1*v
    plus.append(plus_accumulate)
    minus.append(minus_accumulate)    
        
minimum_lost = 10**18
for i in range(n-k+1):
    black_lost = minus[i+k] - minus[i]
    white_lost = plus[i+k] - plus[i]
    minimum_lost = min(minimum_lost, black_lost, white_lost)

print(plus_accumulate - minimum_lost)

Measured memory_bytes: 14388
from operator import itemgetter
import heapq
N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))
X.sort(key=itemgetter(0))
Y.sort(key=itemgetter(0))
G = [[] for _ in range(N)]
for i in range(N-1):
    G[X[i][1]].append((X[i+1][0]-X[i][0], X[i+1][1]))
    G[X[i+1][1]].append((X[i+1][0]-X[i][0], X[i][1]))
    G[Y[i][1]].append((Y[i+1][0]-Y[i][0], Y[i+1][1]))
    G[Y[i+1][1]].append((Y[i+1][0]-Y[i][0], Y[i][1]))

q = []
heapq.heapify(q)
for elem in G[0]:
    heapq.heappush(q, elem)
used = [False] * N
used[0] = True
ans = 0
while q:
    res = heapq.heappop(q)
    cost, nq = res
    if not used[nq]:
        used[nq] = True
        ans += cost
        for elem in G[nq]:
            heapq.heappush(q, elem)
print(ans)


Measured memory_bytes: 79696
from heapq import heappush, heappop
inf = float('inf')
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist

class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)

        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

H,W = map(int,input().split())
Ch,Cw = map(int,input().split())
Dh,Dw = map(int,input().split())
S = [input() for _ in range(H)]

Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

u = UnionFind(H*W)
for sh in range(H):
    for sw in range(W):
        if S[sh][sw]=='#':
            continue
        for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]:
            if 0<=sh+dx<=H-1 and 0<=sw+dy<=W-1 and S[sh+dx][sw+dy]=='.':
                    u.union(sh*W+sw,(sh+dx)*W+sw+dy)
d = {}
n = 0
for sh in range(H):
    for sw in range(W):
        f = u.find(sh*W+sw)
        if f not in d:
            d[f] = n
            n += 1

graph = [[] for _ in range(len(d))]
for sh in range(H):
    for sw in range(W):
        if S[sh][sw]=='#':
            continue
        f1 = u.find(sh*W+sw)
        for dx in range(-2,3):
            for dy in range(-2,3):
                if 0<=sh+dx<=H-1 and 0<=sw+dy<=W-1 and S[sh+dx][sw+dy]=='.':
                        f2 = u.find((sh+dx)*W+sw+dy)
                        graph[d[f1]].append((1,d[f2]))

dist = dijkstra(graph, len(d), d[u.find(Ch*W+Cw)])
ans = dist[d[u.find(Dh*W+Dw)]]
if ans == inf:
    ans = -1
print(ans)

Measured memory_bytes: 348424
s = gets.to_i

def fn (n)
  if n.even?
    n/2
  else
    3*n+1
  end
end

m = 0
a = Array.new(1000001, 0)
a[1] = s
2.upto(1000000) do |i|
  result = fn(a[i-1])
  if a.include?(result)
    m = i
    break
  else
    a[i] = result
  end
end

puts m

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    ll i;
    ll res=0;
    for(i=1;i<=n;i++)
    {
        ll cc = n%i;
        ll aa = n/i;
        res+=aa;
        if(cc==0)
        {
            res--;
        }
    }
    cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

struct UF{
    int par[100000];
    int rank[100000];
    int g[100000];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            g[i]=1;
        }
    }

    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }

    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x!=y){
            if(rank[x]<rank[y]){
                par[x]=y;
                g[y]+=g[x];
                g[x]=0;
            }else{
                par[y]=x;
                if(rank[x]==rank[y])rank[x]++;
                g[x]+=g[y];
                g[y]=0;
            }
        }
    }

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

int main(void){
    int n, m;
    vector<int> v[100000];
    UF u;
    set<int> s;
    cin>>n>>m;
    u.init(n);
    for(int i=0;i<m;i++){
        int x, y, z;
        cin>>x>>y>>z;
        x--;
        y--;
        u.unite(x, y);/*
        if(z%2==0){

        }else{
            v[x].push_back(y);
        */
    }/*
    for(int i=0;i<n;i++){
        for(int j=1;j<v[i].size();j++){
            u.unite(v[i][j], v[i][j-1]);
        }
    }*/
    for(int i=0;i<n;i++){
        s.insert(u.find(i));
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 8448