akhauriyash/Code-Regression huggingface dataset:
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int x, y;
    cin >> x >> y;
    if (y&1) {
        cout << "No";
    }
    else {
        if ((y/2 - x) >= 0 && (2*x - y/2) >= 0) {
            cout << "Yes";
        }
        else cout << "No";
    }
    return 0;
}




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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int,int> P;

int main() {
    int n; cin >> n;
    vector<queue<int>> a(n, queue<int>());


    rep(i, n) rep(j, n-1) {
            int tmp;
            cin >> tmp;
            a[i].push(tmp-1);
    }


    vector<bool> mached(n, false);
    set<P> q;
    auto check = [&](int i) {
        if(a[i].size() == 0) return;
        int j = a[i].front();
        if(a[j].size() == 0) return;
        if(a[j].front() == i) {
            P p(i, j);
            if(p.second < p.first) swap(p.first, p.second);
            q.insert(p);
        }
    };
    rep(i, n) check(i);
    int ans = 0;

    while(q.size() > 0) {
        ans++;
        set<P> prevQ;
        swap(prevQ, q);

        // 今日実施できる試合を消化する
        for(P p : prevQ) {
            int i = p.first, j = p.second;

            // その日の試合を消化する
            a[i].pop();
            a[j].pop();
        }
        for(P p : prevQ) {
            int i = p.first, j = p.second;
            // 次の日にできる試合をチェックする
            check(i);
            check(j);
        }
    }
    rep(i, n) {
        if(a[i].size() != 0) {
            puts("-1");
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

long long val[1 << 19];
string S;
vector<int> vec;

int main() {
	cin >> S;
	if (S[0] == '<') vec.push_back(0);
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == '>' && S[i + 1] == '<') vec.push_back(i + 1);
	}
	if (S[S.size() - 1] == '>') vec.push_back(S.size());

	for (int pos : vec) {
		if (pos >= 1) {
			// 左方向に行く
			val[pos] = 0; long long cnt = 0;
			for (int i = pos - 1; i >= 0; i--) {
				if (S[i] == '<') break;
				cnt++;
				val[i] = max(val[i], cnt);
			}
		}
		if (pos < S.size()) {
			val[pos] = 0; long long cnt = 0;
			for (int i = pos; i < S.size(); i++) {
				if (S[i] == '>') break;
				cnt++;
				val[i + 1] = max(val[i + 1], cnt);
			}
		}
	}

	long long ans = 0;
	for (int i = 0; i <= S.size(); i++) ans += val[i];
	cout << ans << endl;
	return 0;
}

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

int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;

    int ans =0;
    if(x*2==w and y*2==h){
        ans = 1;
    }

    cout << fixed << setprecision(6) << double(h)*double(w) /2 << ' ' << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<climits>

using namespace std;

int main(void) {
	
	int a,b,c,d;
	int sum;
	cin >> a;
	cin >> b;
	if (a > b)sum = b;
	else sum = a;
	cin >> c;
	cin >> d;
	if (c > d)sum += d;
	else sum += c;

	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
using namespace std;
#define pi M_PI

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a == b){
        cout << c << endl;
    }
    else if(b == c){
        cout << a << endl;
    }
    else if(c == a){
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

main = do
    givenstr <- getContents
    forM_ ((zip [1..] . map (read :: (String -> Integer)) . lines ) givenstr) $ \i -> do
        if (snd i == 0) then return () else putStrLn ("Case " ++ (show $ fst i) ++ ": " ++ (show $ snd i))

Measured memory_bytes: 5040
from collections import defaultdict

h, w, m = map(int, input().split())

cnt_h = [0] * h
cnt_w = [0] * w
dic = defaultdict(int)

for _ in range(m):
    h_m, w_m = map(int, input().split())
    cnt_h[h_m - 1] += 1
    cnt_w[w_m - 1] += 1
    dic[(h_m - 1, w_m - 1)] += 1

max_h = max(cnt_h)
max_w = max(cnt_w)

mh = []
mw = []

for i in range(h):
    if max_h == cnt_h[i]:
        mh.append(i)

for i in range(w):
    if max_w == cnt_w[i]:
        mw.append(i)

flag = False
for i in mh:
    for j in mw:
        if dic[(i, j)] == 0:
            flag = True
            break
    if flag:
        break

if flag:
    print(max_h + max_w)
else:
    print(max_h + max_w - 1)

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

int main()
{
    int n; cin >> n;
    vector<ll> a(n + 1);
    for (int i = 0; i < n + 1; i++) cin >> a[i];
    
    ll mons = 0;
    for (int i = 0; i < n; i++) {
        ll b; cin >> b;
        if (b <= a[i]) {
            mons += b;
        } else if (b <= a[i] + a[i + 1]) {
            mons += b;
            a[i + 1] -= (b - a[i]);
        } else {
            mons += (a[i] + a[i + 1]);
            a[i + 1] = 0;
        }
    }
    cout << mons << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

const int maxn = 3001;
ll dp[maxn][maxn][4];
int grid[maxn][maxn];

void updMx(ll &mx , ll cand){
    mx = max(mx, cand);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, q, i, j, k;
    cin >> n >> m >> q;
    for(i=0;i<q;i++){
        int r,c;
        cin >> r >> c;r--;c--;
        cin >> grid[r][c];
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            for(k=0;k<=3;k++){
                if(i == 0 && j == 0){
                    dp[i][j][k] = k == 0 ? 0 : grid[i][j];
                    continue;
                }
                if(i){
                    if(k)
                        dp[i][j][k] = dp[i-1][j][3] + grid[i][j];
                    else
                        dp[i][j][k] = dp[i-1][j][3];
                }
                if(j){
                    updMx(dp[i][j][k], dp[i][j-1][k]);
                    if(k){
                        updMx(dp[i][j][k], dp[i][j-1][k-1] + grid[i][j]);
                    }
                }
            }
        }
    }
    cout << dp[n-1][m-1][3] << "\n";
    
    return 0;
}

Measured memory_bytes: 319976
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
 
    int n, k, i;
    cin >> k >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    int ans=A[n-1]-A[0];
    for(i=1; i<n; i++){
      int e = k - A[i] + A[i-1];
      if(e<ans) ans = e;   
    }
    cout << ans << endl; 
}


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second

ll N,M;
ll x[1005],y[1005],z[1005];
ll xyz[10][1005];
ll s[10];
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>M;

rep(i,N){
	cin>>x[i]>>y[i]>>z[i];

	xyz[0][i]=x[i]+y[i]+z[i];
	xyz[1][i]=x[i]+y[i]-z[i];
	xyz[2][i]=x[i]-y[i]+z[i];
	xyz[3][i]=-x[i]+y[i]+z[i];
	xyz[4][i]=x[i]-y[i]-z[i];
	xyz[5][i]=-x[i]-y[i]+z[i];
	xyz[6][i]=-x[i]+y[i]-z[i];
	xyz[7][i]=-x[i]-y[i]-z[i];
}

rep(i,8){
	sort(xyz[i],xyz[i]+N,greater<ll>());
}

rep(i,8){
	rep(j,M){
		s[i]+=xyz[i][j];
	}
}

rep(i,8){
	ans=max(ans,s[i]);
}

cout<<ans<<endl;


}
	


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
using namespace std;
 
#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;
 
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector<ii> vii;
 
const int N = int(2e5)+10;
const int K = 10005;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

const ll MOD = 998244353;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve () {
    string s;cin>>s;
    if (s == "ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3540
from collections import Counter
N = int(input())

A = list(map(int, input().split()))
Q = int(input())

ans = sum(A)
d = Counter(A)

for i in range(Q):
    b, c = map(int,input().split())
    tmp = d[b] 
    d[b] = 0
    d[c] += tmp
    ans += (c-b)*tmp
    print(ans)


Measured memory_bytes: 24280
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define INARR(h,w,x,y) (0 <= y && y < h && 0 <= x && x < w)

using namespace std;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<bool> VB;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};
using namespace std;
//エラトステネスのふるい
template<typename T>
vector<bool> Eratosthenes(T n) { // 素数がtrueのテーブル
	vector<bool> table(n+1,true);
	table[0] = false;
	T maxiter = sqrt(n);
	for(T i = 2;i < maxiter+1;i++){
		if (table[i]) {
			for (T j = (i + i);j <= n;j += i){
				table[j] = false;
			}
		}
	}
	return table;
}

int main(void) {
	long Q;
	cin >> Q;
	VB tb = Eratosthenes<long>(100000);
	tb[1] = false;
	VI acc(100001,0);
	FOR(i,1,100001) {
		if (!(i % 2)) acc[i] = acc[i-1];
		else {
			if (tb[i] && tb[(i+1)/2]) acc[i] = acc[i-1]+1;
			else acc[i] = acc[i-1];
		}
	}
	long l,r;
	REP(i,Q) {
		cin >> l >> r;
		cout << acc[r]-acc[l-1] << endl;
	}
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

const int nax = 1e3+5;
const int inf = 1e18+7;
const int mod = 1e9+7;

int n,m;
char a[nax][nax], b[nax];
vector<int>adj[nax];

/*
 * 	   ************************ If you gave me a chance *******************************
 * 	   ************************ I'll take it            *******************************
 * 	   ************************	It's a shot in the dark *******************************
 * 	   ************************	But I will make it:D    *******************************
 */
int dp[nax][nax];
signed main(){
    fast;

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

    memset(dp,0,sizeof(dp));
    dp[1][1] = 1;
    for (int i = 2; i <= m;i++ ){
        if(a[1][i]=='.'){
            dp[1][i] = dp[1][i - 1];
        }if(a[1][i] == '#'){
            dp[1][i] = 0;
        }
    }
    for (int i = 2; i <= n;i++){
        if(a[i][1]=='.'){
            dp[i][1] = dp[i - 1][1];
        }if(a[i][1] =='#'){
            dp[i][1] == 0;
        }
    }
    for (int i = 2; i <= n;i++){
        for (int j = 2; j <= m;j++){
            if(a[i][j] == '.'){
                dp[i][j] = max(dp[i][j], ((dp[i - 1][j] + dp[i][j - 1])%mod+mod)%mod);
            }else{
                dp[i][j] = 0;
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}


Measured memory_bytes: 12456
# coding: utf-8
from collections import Counter
alp=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
INF=10**9
D=[]

N=int(input())
for i in range(N):
    S=list(input())
    D.append(Counter(S))
L=[INF for i in range(26)]

for i in range(26):
    for j in range(N):
        L[i]=min(L[i],D[j][alp[i]])
ans=""

for i in range(26):
    for j in range(L[i]):
        ans+=alp[i]

print(ans)

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

int main(){
	int x[6];
	int u = 0;
	int day = 0;

	while(cin >> x[0], x[0] != -1){
		for(int i = 1; i < 6; i++)
			cin >> x[i];
		while(1){
			 if(x[0] == x[3] && x[1] == x[4] && x[2] == x[5]){
				 break;
				}else{
					x[5]--; day++;
					if(x[5] == 0){
						x[4]--;
						if(x[4] != 2 && (x[4] == 2 || x[4] == 4 || x[4] == 6 || x[4] == 9 || x[4] == 11)){
							x[5] = 30;
						}else if(x[4] != 2){
							x[5] = 31;
						}else{
							if(x[3] % 4 == 0 && (x[3] % 100 != 0 || x[3] % 400 == 0)){
								x[5] = 29;
							}
							else
								x[5] = 28;
						}
					}
					if(x[4] == 0){
						x[4] = 12;
						x[3]--;
					}
				}
		}
	cout << day << endl;
	day = 0;
	}
}

Measured memory_bytes: 1160
N=int(input())
alist=list(map(int,input().split()))

def bs_left(mid,mp):
  sum2=abs(2*slist[mid]-slist[mp])
  if mid==0:
    sum1=sum2
  else:
    sum1=abs(2*slist[mid-1]-slist[mp])
  if mid==mp:
    sum3=sum2
  else:
    sum3=abs(2*slist[mid+1]-slist[mp])

  if sum2<=sum1 and sum2<=sum3:
    return 0
  elif sum1<sum2:
    return -1
  elif sum2>sum3:
    return 1    

def bs_right(mid,mp):
  sum2=abs(2*(slist[mid]-slist[mp])-(slist[-1]-slist[mp]))
  if mid==0:
    sum1=sum2
  else:
    sum1=abs(2*(slist[mid-1]-slist[mp])-(slist[-1]-slist[mp]))
  if mid==mp:
    sum3=sum2
  else:
    sum3=abs(2*(slist[mid+1]-slist[mp])-(slist[-1]-slist[mp]))

  if sum2<=sum1 and sum2<=sum3:
    return 0
  elif sum1<sum2:
    return -1
  elif sum2>sum3:
    return 1    
  
slist=[]
asum=0
for a in alist:
  asum+=a
  slist.append(asum)
#print(alist)
#print(slist)

dic_lp,dic_rp={},{}
for mp in range(1,N-2):  
  #lp
  l,r=0,mp-1
  while(l<=r):
    mid=(l+r)//2
    ret=bs_left(mid,mp)
    if ret==1:
      l=mid+1
    elif ret==-1:
      r=mid-1
    else:
      dic_lp[mp]=mid
      #print(mp,mid)
      break
  
  #rp
  l,r=mp+1,N-2
  while(l<=r):
    mid=(l+r)//2
    ret=bs_right(mid,mp)
    if ret==1:
      l=mid+1
    elif ret==-1:
      r=mid-1
    else:
      dic_rp[mp]=mid
      #print(mp,mid)
      break
    
min_diff=10**9
for mp in range(1,N-2):
  lp=dic_lp[mp]
  rp=dic_rp[mp]
  
  sum1=slist[lp]
  sum2=slist[mp]-slist[lp]
  sum3=slist[rp]-slist[mp]
  sum4=slist[-1]-slist[rp]
  #print(sum1,sum2,sum3,sum4)
  
  sum_list=[sum1,sum2,sum3,sum4]
  sum_list.sort()
  diff=sum_list[-1]-sum_list[0]
  #print(lp,mp,rp,diff)
  if diff<min_diff:
    min_diff=diff    
  
print(min_diff)


Measured memory_bytes: 122420
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n,p,cnt=0,ans=0;
	in(n);
	vll list(n + 1,-1);
	rep(i, 0, n) {
		in(p);
		list[p] = i;
	}

	repeq(i, 1, n) {
		if (list[i] - list[i - 1] > 0) {
			cnt++;
		}
		else {
			ans = max(ans, cnt);
			cnt = 1;
		}
	}

	ans = max(ans, cnt);
	cnt = 0;

	outn(n - ans);

	return 0;


}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  g[x - 1].push_back(y - 1);
  g[y - 1].push_back(x - 1);
  vector<int> d(2 * n);
  for (int i = 0; i < n; i++) {
    vector<int> dist(n, -1);
    dist[i] = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int v : g[u]) {
        if (dist[v] == -1) {
          dist[v] = 1 + dist[u];
          q.push(v);
        }
      }
    }
    for (int j = 0; j < n; j++) {
      d[dist[j]]++;
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    cout << d[i] / 2 << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
// AOJ 2944 Equal Split
// 2019.8.8 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 正整数の表示（出力）
	int i;
	char b[20];
	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
	pc('\n');
}

int main()
{
	int i, a, N, M, ans;
	
	while (N = in()) {
		M = in(), M /= N;
		ans = 0;
		for (i = 0; i < N; i++) {
			a = in();
			ans += (a >= M)? M: a;
		}
		out(ans);
	}
	return 0;
}


Measured memory_bytes: 2044
N = int(input())
ans = 0
if N <= 356:
  print(0)
else:
  L = ['3','5','7']
  for i in range(len(str(N))-1):
    for j in range(len(L)):
      L.append(L[j]+'3')
      L.append(L[j]+'5')
      L.append(L[j]+'7')
    K = list(set(L))
    ans = 0
  for i in range(len(K)):
    if K[i].count('3') > 0:
      if K[i].count('5') > 0:
        if K[i].count('7') > 0:
          if int(K[i]) <= N:
            ans += 1
  print(ans)

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

inline bool is_valid(int i, int j) {
    return j >= 0 && i/2 - 1 <= j && j <= (i+1) / 2;
}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    vector<vector<int64_t>> dp(3, vector<int64_t>((N+1)/2 + 1));
    dp[1][0] = 0;
    dp[1][1] = A[0];
    for (int i = 2; i <= N; ++i) {
        for (int j = i/2 - 1; j <= (i+1) / 2; ++j) {
            int64_t v1 = is_valid(i-2, j-1) ? dp[(i-2)%3][j-1] + A[i-1]
                                            : numeric_limits<int64_t>::min();
            int64_t v2 = is_valid(i-1, j) ? dp[(i-1)%3][j]
                                          : numeric_limits<int64_t>::min();
            dp[i%3][j] = max(v1, v2);
        }
    }
    cout << dp[N%3][N/2] << '\n';
}


Measured memory_bytes: 7184
#include <stdio.h>

int main() {

	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (0 <= (x - r) && 0 <= (y - r) && (x + r) <= W && (y + r) <= H) {
		printf("Yes\n");
	}else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2104
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
#define vv(t) vector< t > 

#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))

template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}

#pragma endregion

template<typename T>
void SV(vector<T> v){
    #ifdef LOCAL
        REP(i,v.size()){
                cout << i << " : " << v[i] << endl;
        }
    #endif
}

template<typename T>
void SV(map<int, T> v){
    #ifdef LOCAL
        FOREACH(i, v){
            cout << i.first << " : " << i.second << endl;
        }
    #endif
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

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

ll f(ll a, ll b){
    if(b==1)
        return a;
    return (a*f(a, b-1))%998244353;
}

int main(void){
    int N;
    ll sum=0;
    cin >> N;
    ll mins=LONG_LONG_MAX;
    ll cnts=0;
    REP(i, N){
        ll t;
        cin >> t;
        if(t<0){
            t=-t;
            cnts++;
        }
        mins=min(mins, t);
        sum+=t;
    }
    debug(cnts, sum, mins);
    if(cnts%2){
        sum-=2*mins;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <queue>
#include <cmath>
using namespace std;


int GetDigit(int n){
	int i = 0;

	while(n > 0){
		n /= 10;
		i++;
	}

	return i;
}
 
int main(){
	double a, b, c, d, e, f;
	double x, y;

	cout.flags(ios::fixed);
	cout.precision(3);
	
	while(cin >> a >> b >> c >> d >> e >> f){
		x = (c*e-b*f)/(a*e-b*d);
		y = (c*d-a*f)/(b*d-a*e);

		if(x == -0.0) x = abs(x);
		if(y == -0.0) y = abs(y);
		cout << x << ' ' << y << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
// Problem : D - Sum of Large Numbers
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	ll minSum = 0, maxSum = 0;
	FOR(i, 0, k - 1) minSum += i;
	FORD(i, n, n + 1 - k) maxSum += i;
	FOR(i, k, n) {
		//cout << minSum << " " << maxSum << endl;
		ans += (maxSum - minSum + 1);
		ans %= MOD;
		minSum += i;
		maxSum += (n - i);
	}
	cout << (ans + 1) % MOD << endl;
	return 0;
}
 


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int n;
int cnt1 = 0; 
vector<int> d(n);
vector<int> f(n);
void dfs(const Graph &G, int v){
    cnt1++;
    d[v - 1] = cnt1;
    for(auto nv : G[v - 1]){
        if(d[nv - 1] != 0) continue;
        dfs(G, nv);
    }
    cnt1++;
    f[v - 1] = cnt1;
}

int main(){
    cin >> n;
    Graph G(n); 
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        if(b == 0) continue;
        for(int j = 0; j < b; j++){
            int x; cin >> x;
            G[a - 1].push_back(x);
        }
    }
    d.assign(n, 0);
    f.assign(n, 0);
    for(int i = 1; i <= n; i++){
      if(d[i - 1] == 0) dfs(G, i);
    }
    for(int i = 1; i <= n; i++){
        cout << i << " " << d[i - 1] << " " << f[i - 1] << endl; 
    }
}


Measured memory_bytes: 3120
fun main(args: Array<String>){
	//Hello_World()
	//X_Cubic()
	//Rectangle()
	//Watch()
	//Small_Large_or_Equal()
	//Range()
	Sorting_Three_Numbers()
}

fun Sorting_Three_Numbers(){
	val abc = readLine()!!.split(" ").map(String::toInt)
	val abc_sorted = abc.sorted()
	println("${abc_sorted[0]} ${abc_sorted[1]} ${abc_sorted[2]}")
}


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

const int INF=1e5;

int costs[10]={INF,
    0,INF,INF,INF,INF,
    INF,INF,INF,INF};
int c[10][10];
void solve(){
    for(int l=0; l<10; l++){
        for(int k=0; k<10; k++){
            for(int i=0; i<10; i++){
                for(int j=0; j<10; j++){
                    c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
                }
            }
        }
    }
    for(int i=0; i<10; i++){
        costs[i]=min(costs[i],c[i][1]);
    }
}


int main(){
    int H, W;
    cin>>H>>W;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin>>c[i][j];
        }
    }
    solve();
    int A;
    long long ans=0LL;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A;
            if(A!=-1)ans+=costs[A];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int t[100005],x[100005],y[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d %d %d",&t[i],&x[i],&y[i]);
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		int k=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])-abs(t[i]-t[i-1]);
		if(abs(k)%2==1||k>0)
		{
			flag=1;
			break;
		}
	}
	if(flag)
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void)
{
    char s[5];
    scanf("%s", s);
    rep(i, 3)
    {
        if (s[i] == s[i + 1])
        {
            puts("Bad");
            return 0;
        }
    }

    puts("Good");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#include<map>
#include<cmath>
#include<algorithm>
#define int long long int
bool prime(int x)
{
	if(x==1||x==4)
	    return false;
	if(x==2||x==3||x==5)
	    return true;
   else if(x%2==0||x%3==0||x%5==0)
        return false;
    for(int i=7;i*i<=x;i++)
    {
		if(x%i==0)
		   return false;
	}
	return true;
}
int32_t main()
{
    int n;
    cin>>n;
    int j,arr[n];
    for(j=0;j<n;j++)
        cin>>arr[j];
    int arr2[n];
    for(j=0;j<n;j++)
         arr2[j]=arr[j];
    sort(arr2,arr2+n);
    for(j=0;j<n;j++)
    {
		if(arr[j]==arr2[n-1])
		    cout<<arr2[n-2]<<endl;
		else
		   cout<<arr2[n-1]<<endl;
	}
	//cout<<endl;
}


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

int main() {
	int k,n;cin>>k>>n;
  vector<int> a(n);
  int mx=0;
  rep(i,n){
    cin>>a[i];
    if(i==0)continue;
  
    mx = max(mx,a[i]-a[i-1]);
  }
  int d = a[n-1]-a[0];
  if(d>10)d = k-d;
  mx = max(mx,d);
  cout<<k-mx;
  
  

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,x,bf,ans=0;
  cin>>N;
  vec v,a(N-1);
  cin>>bf;
  rep1(i,N){
    cin>>x;
    if(bf==x-1)v.push_back(bf-1);
    bf=x;
  }
  rep(i,N){
    cin>>x;
    ans+=x;
  }
  rep(i,N-1){
    cin>>a[i];
  }
  rep(i,(ll)v.size()){
    ans+=a[v[i]];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
S = {}
for i in range(n):
    s = str(input())
    if s not in S:
        S[s] = 1
    else:
        S[s] += 1
m = int(input())
T = {}
for i in range(m):
    t = str(input())
    if t not in T:
        T[t] = 1
    else:
        T[t] += 1

ans = 0
for k, v in S.items():
    if k in T:
        ans = max(ans, v-T[k])
    else:
        ans = max(ans, v)
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	if (k <= x / d) {
		cout << x - k*d;
	}
	else {
		if ((k - (x / d)) % 2 == 0)cout << x%d;
		else cout << abs(x%d - d);
	}
	
}


Measured memory_bytes: 3624
n = gets.to_i
h = Hash.new(0)
s = gets.chomp.chars
s.each do |x|
  h[x] += 1
end
n.pred.times do
  s = gets.chomp.chars
  g = Hash.new(0)
  f = {}
  s.each do |x|
    g[x] += 1
  end
  g.keys.each do |k|
    if h.key?(k)
      if h[k] > g[k]
        f[k] = g[k]
      else
        f[k] = h[k]
      end
    end
  end
  h = f
end
ans = ''
h.sort_by{|k, v| k}.each do |k, v|
  ans.concat(k * v)
end
puts ans

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,a,b,y,z;
    cin>>x>>a>>b;
    if(x-a<0){
        y=a-x;
    }
    else{
        y=x-a;
    }
    if(x-b<0){
        z=b-x;
    }
    else{
        z=x-b;
    }
    if(y>z){
        cout<<"B"<<endl;
    }
    else{
        cout<<"A"<<endl;
    }

}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(5);
  rep(i,5){
    cin >> a[i];
  }
  ll ans;
  if (n%(*min_element(a.begin(),a.end()))==0) ans = n/(*min_element(a.begin(),a.end()))+4;
  else ans = n/(*min_element(a.begin(),a.end()))+5;
  
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("CODEFESTIVAL2016"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>s;
      rep(i,Size(s)){
        if(s[i]!=alph[i])ans++;
      }
      Cout(ans);
    
       
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;
ll a[100010],N,ans1=0,ans2=0;
int main(void)
{
	cin >> N;
	FOR(i, 0, N)cin >> a[i];
	sort(a, a + N);
	ll i = 0;
	if (N % 2 == 1) {
		FOR(k, 0, (N - 1) / 2 - 1) {
			ans1 -= 2 * a[i];i++;
		}
		ans1 -= a[i] + a[i + 1]; i += 2;
		FOR(k, 0, (N - 1) / 2) {
			ans1 += 2 * a[i];i++;
		}
		i = 0;
		FOR(k, 0, (N - 1) / 2) {
			ans2 -= 2 * a[i];i++;
		}
		ans2 += a[i] + a[i + 1]; i += 2;
		FOR(k, 0, (N - 1) / 2 - 1) {
			ans2 += 2*a[i]; i++;
		}
	}
	else {
		FOR(k, 0, (N / 2)-1) {
			ans1 -= a[i] * 2; i++;
		}
		ans1 -= a[i]-a[i+1]; i+=2;
		FOR(k, 0, (N / 2) - 1) {
			ans1 += 2 * a[i]; i++;
		}
	}
	ct(max(ans1,ans2));
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    string s; cin >> s;
    bool is[26];
    rep(i, 0, 26) is[i] = false;
    rep(i, 0, s.size()) is[s[i] - 'a'] = true;
    rep(i, 0, 26) {
        if (!is[i]) {
            cout << (char)(i + 'a') << endl;
            exit(0);
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
// Dedication has no limitation
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
set<int> p;
for(int i=0; i<4; i++){
	p.insert(s[i]);
}

if(p.size()==2){
	cout << "Yes" << endl;
	return 0;
}

cout << "No" << endl;

}

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

bool isprime(int a)
{
    if(a == 2)
        return true;
    else if(a < 2 || a%2 == 0)
        return false;
    else
    {
        for(int i = 3;i < (int)sqrt(a) + 1;i += 2)
        {
            if(a % i == 0)
            {
                return false;
            }
        }
        return true;
    }
}

int main()
{
    int n;
    int cnt = 0;
    cin>>n;
    for(int i = 0;i < n;i++)
    {
        int in;
        cin>>in;
        if(isprime(in))
            cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3108
k = int(input())

al = []
def f(d, v, al):
    
    al.append(v)
    
    if d == 10:
        return
    
    for i in range(-1,2):
        add = (v%10) + i
        if add >= 0 and add <= 9:
            f(d+1, v*10+add, al)
            
            
for i in range(1,10):
    f(0, i, al)
    
al = sorted(al)

print(al[k-1])

Measured memory_bytes: 45216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
      cin>>n;
       string s;
         cin>>s;

   int count=0;
       for(int i=0;i<n;i++)
        {
            if(i==0)
             count++;

             else
             {
                 if(s[i]!=s[i-1])
                  count++;
             }
        }
      cout<<count;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)
class Point {
public:
	long double x, y;
	Point(long double x = 0, long double y = 0) :x(x), y(y) {}
	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(x*a, y*a); }
	Point operator / (double a) { return Point(x / a, y / a); }
	long double abs() { return sqrt(norm()); }
	long double norm() { return x*x + y*y; }
	bool operator < (const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
	bool operator > (const Point &p) const { return x != p.x ? x > p.x : y > p.y; }
	bool operator == (const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }
};
struct Segment {
	Point p1, p2;
};
long double norm(Point p) { return p.x*p.x + p.y*p.y; }
long double abs(Point p) { return sqrt(norm(p)); }
double dot(Point a, Point b) {
	return a.x*b.x + a.y*b.y;
}
Point projection(Segment a, Point b) {
	Point sa = a.p2 - a.p1;
	double hyp = dot(b - a.p1, sa); double r = hyp / norm(sa);
	return a.p1 + sa * r;
}
int main() {
	Point P1, P2; Segment G; int q;
	cin >> P1.x >> P1.y >> P2.x >> P2.y;
	G.p1 = P1; G.p2 = P2; cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> P1.x >> P1.y;
		Point S = projection(G, P1);
		cout << fixed << setprecision(15) << S.x << ' ' << fixed << setprecision(15) << S.y << endl;
	}
	return 0;
}

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

int main(){
        ll s; cin>>s;

        ll v=1000000000;

        ll x=(v-s%v)%v;
        ll y=(s+x)/v;

        cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}


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

namespace KyouProg
{
    class Program
    {
        public int N = 1000;
        public int Lcs(string X, string Y)
        {
            int m = X.Length;
            int n = Y.Length;
            int[,] c = new int[m + 1, n + 1];

            for (int i = 0; i <= m; i++)
            {
                c[i, 0] = 0;
            }
            for (int j = 1; j <= n; j++)
            {
                c[0, j] = 0;
            }
            for(int i = 1; i<= m; i++)
            {
                for(int j = 1; j <= n; j++)
                {
                    if (X[i-1] == Y[j-1])
                    {
                        c[i, j] = c[i - 1, j - 1] + 1;
                    }
                    else
                    {
                        if (c[i - 1, j] >= c[i, j - 1])
                        {
                            c[i, j] = c[i - 1, j];
                        }
                        else
                        {
                            c[i, j] = c[i, j - 1];
                        }
                    }
                }
            }
            return c[m, n];
        }

        static void Main(string[] args)
        {
            int cmdN = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < cmdN; i++)
            {
                string X = Console.ReadLine().Trim();
                string Y = Console.ReadLine().Trim();
                Program obj = new Program();
                int ans = obj.Lcs(X, Y);
                Console.WriteLine(ans);
            }
        }
    }
}



Measured memory_bytes: 35052
#include <cstdio>
#include <iostream>
#include <bitset>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
 
using namespace std;
typedef long long ll;
 
#define ALL(obj) (obj).begin(), (obj).end() 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)

#define MOD 1000000007

ll fact[4040404], frev[4040404];
ll invs[4040404];

ll comb(int n, int k)
{
	if (n < k) return 0;
	return fact[n] * frev[k] % MOD * frev[n - k] % MOD;
}

void fill_combination_table(){
	fact[0] = 1; frev[0] = 1;
	invs[0] = 1;
	invs[1] = 1;
	for (int i = 2; i < 4040404; ++i) invs[i] = MOD - MOD / i * invs[MOD % i] % MOD;
	for (int i = 1; i < 4040404; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
		frev[i] = frev[i - 1] * invs[i] % MOD;
	}
}

ll dp[4040][2020];

int main(){
    ll n,k;
    cin >> n >> k;
    if(k==1){ cout << "1" << endl; return 0;}
    dp[1][1] = 1;
    dp[0][1] = 1;
        fill_combination_table();
    FOR(j,2,n+1){
        dp[0][j] =  comb((j * (k - 1)) - 1, k - 2) * dp[0][j-1] % MOD;
       // cout << "comb n=" << (j * (k - 1)) - 1 << ",k="<< k-1 <<" : "<<comb((j * (k - 1)) - 1, k - 2) << endl;
        //cout << "dp[0][" << j <<"] : " << dp[0][j] << endl;
    }

    FOR(i,1,n+1){
        FOR(j,i,n+1){
            dp[i][j] =  (dp[i-1][j] + ((comb(i + (j * (k - 1)) - 1, k - 2) * dp[i][j-1]) % MOD)) % MOD ;
         //   cout << "comb n=" << i + (j * (k - 1)) - 1 << ",k="<< k-1 <<" : "<<comb((j * (k - 1)) - 1, k - 2) << endl;
        //    cout << "dp["<< i << "][" << j <<"] : " << dp[i][j] << endl;
        }
    }
    //cout << comb(3,1) << endl;
    cout << (dp[n][n] * fact[n]) % MOD << endl;

    return 0;
}

Measured memory_bytes: 128000
local n, c, k = io.read("*n", "*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
table.sort(t)
local ans = 0
local curnum, curtime = 0, -1000000007
for i = 1, n do
  if curnum == c or curtime + k < t[i] then
    ans = ans + 1
    curnum = 0
    curtime = t[i]
  end
  curnum = curnum + 1
end
print(ans)


Measured memory_bytes: 2424
s=list(input())
from collections import deque
l=deque(s)
q=int(input())
m=1
for _ in range(q):
    x=list(input().split())
    if x[0]=="1":
        m*=-1
    else:
        f,c=x[1],x[2]
        f=int(f)
        if f==1:
            if m==1:
                l.appendleft(c)
            else:
                l.append(c)
        else:
            if m==1:
                l.append(c)
            else:
                l.appendleft(c)
if m==1:
    print("".join(l))
else:
    l.reverse()
    print("".join(l))


Measured memory_bytes: 75128
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    val MOD = 1000000007L
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val S = sc.next().toInt()
        val dp = LongArray(2001)
        dp[3] = 1
        dp[4] = 1
        dp[5] = 1
        for (i in 6..2000) {
            var a = 1L
            for (j in 3..(i - 3)) {
                a += dp[j]
                a %= MOD
            }
            dp[i] = a
        }
        pw.println(dp[S])
    }
}


Measured memory_bytes: 36404
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[100005];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    int current_botan = 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(current_botan == 2) break;

        current_botan = a[current_botan];
        ans++;
    }
    
    if(ans >= n) cout << -1 << endl;
    else cout << ans << endl;

}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
bool solve(int i,int m,int n,int a[])
{
   if(m==0)
      return true;
   if(i>=n)
      return false;
   return solve(i+1,m,n,a)||solve(i+1,m-a[i],n,a);
}





int main()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
      cin>>a[i];
   int q;
   cin>>q;
   int m;
   for(int i=0;i<q;i++)
   {
      cin>>m;
      if(solve(0,m,n,a))
         cout<<"yes"<<endl;
      else
         cout<<"no"<<endl;
   }
   return 0;
}

Measured memory_bytes: 3088