akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h> // double fmod(double x, double y);

 using namespace std;


 int main()
 {
  int n;
  cin >> n;
  int hairetu[n];

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

  int count = 0;
  for(int i=0;i<n;i++)
  {
    if(hairetu[i] != i+1)
    {
      count ++;
    }
  }
  if (count < 3)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    //cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
static ll x;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
        x ++;
    }
}

ll fr(ll n){
    ll ans = 1;
    REP(i, n){
        ans *= i+1;
        ans %= MOD;
    }
    return ans;
}

ll conb(ll n, ll k){
    return fr(n)% MOD * modinv(fr(k) * fr(n-k) % MOD, MOD) % MOD;
}

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



Measured memory_bytes: 3596
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vi vector<ll>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vt vector<tuple<ll, ll, ll>>
using namespace std;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	string s;
	cin >> s;
	s = s.substr(0, s.size() - 2);
	while (s.size())
	{
		string s1 = s.substr(0, s.size() / 2), s2 = s.substr(s.size() / 2, s.size() / 2);
		if (s1 == s2) {
			cout << s.size() << endl;
			return 0;
		}
		else if (s.size()) s = s.substr(0, s.size() - 2);
	}
	cout << "0" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	//cin >> n;
	vector<ll>	aa(6);
	for(i=0;i<5;i++) cin >> aa[i];
	for(i=0;i<5;i++) {
		if (aa[i]==0) break;
	}

	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << i+1 << endl;
	return 0;
}


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

int main(){
  string a,b;
  cin>>a>>b;
  int x = stoi(a+b);
  for (int i=1;i<=10000;i++){
          if (i*i==x){
                   puts("Yes");
                   return 0;
           }
   }
   puts("No");
}


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

using namespace std;

int main(void)
{
  long long n=0;
  long long r=101;
  int i=1;

  cin>>n;

  while(1)
  {
    if(n<=r)
    {
      cout<<i<<endl;
      return 0;
    }
    else
    {
      r*=1.01;
      i++;
    }
  }

  return 0;

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
const ll mod=998244353;
const ll N=1e5+9;
using namespace std;
ll read(ll &x){
    ll dat=0,oko=1;char chc=getchar();
    while(chc<'0'||chc>'9'){if(chc=='-')oko=-1;chc=getchar();}
    while(chc>='0'&&chc<='9'){dat=dat*10+chc-'0',chc=getchar();}
    x=dat*oko;return x;
}ll n,d,num[N],ans,mx;
ll quick(ll a,ll b){
    ll re=1,temp=a;
    while(b){
        if(b&1)re=(re*temp)%mod;
        temp=(temp*temp)%mod,b>>=1;
    }return re;
}int main(){
    read(n),ans=1;
    for(int i=1;i<=n;i++){
        read(d);
        if(i==1&&d){
            printf("0\n");
            return 0;
        }num[d]++;
        mx=max(mx,d);
    }if(num[0]!=1){
        printf("0\n");
        return 0;
    }for(int i=1;i<=mx;i++){
        if(!num[i]){
            printf("0\n");
            return 0;
        }ans=(ans*quick(num[i-1],num[i]))%mod;
    }printf("%lld\n",ans);
    return 0;
}

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

using namespace std; 
int N, K, L;
int p[200004], q[200004], r[200004], s[200004];

vector<int> Adj1[200004], Adj2[200004];

int check1[200004], check2[200004];

void visit1(int M, int p) {
	check1[M] = p;

	for (int h = 0; h < (int)Adj1[M].size(); h++) {
		int K = Adj1[M][h];
		if (check1[K] == 0) { visit1(K, p); }
	}
}

void visit2(int M, int p) {
	check2[M] = p;

	for (int h = 0; h < (int)Adj2[M].size(); h++) {
		int K = Adj2[M][h];
		if (check2[K] == 0) { visit2(K, p); }
	}
}

vector<pair<int, int> > W;
vector<int> V1, V2;

int main(void) {

	cin >> N >> K>>L;

	int tmp;
	for (int i = 1; i <= K; i++) {
		cin >> tmp; p[i] = tmp;
		cin >> tmp; q[i] = tmp;
	}
	for (int j = 1; j <= L; j++) {
		cin >> tmp; r[j] = tmp;
		cin >> tmp; s[j] = tmp;
	}

	for (int i = 1; i <= K; i++) {
		Adj1[p[i]].push_back(q[i]);
		Adj1[q[i]].push_back(p[i]);
	}

	for (int j = 1; j <= L; j++) {
		Adj2[r[j]].push_back(s[j]);
		Adj2[s[j]].push_back(r[j]);
	}

	int p;
	p = 1;
	for (int i = 1; i <= N; i++) {
		if (check1[i] == 0) { visit1(i, p); p++; }
	}

	p = 1;
	for (int i = 1; i <= N; i++) {
		if (check2[i] == 0) { visit2(i, p); p++; }
	}

	
	for (int i = 1; i <= N; i++) {
		W.push_back(pair<int, int>(check1[i],check2[i]));
	}

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

	pair<int, int> P;

	for (int i = 1; i <= N; i++) {
		P.first = check1[i]; P.second = check2[i];
		long long int count = upper_bound(W.begin(), W.end(), P) - lower_bound(W.begin(), W.end(), P);
		if (i != 1) { cout << " "; }
		cout << count;
	}cout << endl;


	/*for (int i = 1; i <= N; i++) {
		cout << "check1[" << i << "]= " << check1[i] << "  check2[" << i << "]= " << check2[i] << endl;
	}*/

	//system("pause");
	return 0;
}

Measured memory_bytes: 22260
<?php
list($n, $k) = ints();
$a = ints();
for ($i = $k; $i < $n; ++$i)
    if ($a[$i] > $a[$i - $k]) $ans[] = 'Yes';
    else $ans[] = 'No';
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main(){
    int n;
    cin>>n;
    
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum +=a[i];
    }
    
    int q;
    cin>>q;
    vector<ll> b(q);
    vector<ll> c(q);
    rep(i,q) cin>>b[i]>>c[i];
    
    vector<ll> num(100005,0);
    rep(i,n) num[a[i]]++;
    
    rep(i,q){
        sum +=(c[i]-b[i])*num[b[i]];
        cout<<sum<<endl;
        num[c[i]]+=num[b[i]];
        num[b[i]]=0;
    }
    
    return 0;
}

Measured memory_bytes: 6420
main :: IO ()
main = do
    [sx, sy, tx, ty] <- map read.words <$> getLine
    putStr $ 'L' : replicate (ty - sy + 1) 'U' ++ replicate (tx - sx + 1) 'R' ++ "D"
    putStr $ 'R' : replicate (ty - sy + 1) 'D' ++ replicate (tx - sx + 1) 'L' ++ "U"
    putStr $ replicate (ty - sy) 'U' ++ replicate (tx - sx) 'R'
    putStr $ replicate (ty - sy) 'D' ++ replicate (tx - sx) 'L'
    putStrLn ""


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

#define long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


map<int,int> m;
vector<pair<string,int>> v;



signed main(){
    int n,a;
    string s;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> s >> a;
        m[a]=i+1;
        v.push_back(make_pair(s,-a));
        //st.insert(make_pair(s,m[s]));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int i = n-1;
    while(i>=0){
        //if(m[v[i].first]>1){


    //else{
        cout << m[-v[i].second] << endl;
        i--;
    }


    return 0;

}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1);
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
N, M=map(int,input().split())
if M==0:
	print("0 0")
else:
	ac=0
	pe=0
	ch=[0]*N
	Ch=[0]*N
	for i in range(M):
		a, b=input().split()
		a=int(a)-1
		if ch[a]==1:
			continue
		elif b=="WA":
			Ch[a]+=1
		else:
			ch[a]=1
			ac+=1
			pe+=Ch[a]
	print(ac,pe)



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vi a;
    a.resize(n);
    REP(i,n) cin>>a[i];
    int ans=0;

    ans=0;
    REP(i,n){
        if(a[i]==ans+1){
            ans++;
        }
    }

    ans = n-ans;
    //DEBUG(ans);
    if(ans==0 || ans==n){
        REP(i,n){
            if(a[i]!=i+1){
                cout << "-1" << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a[5],ans;
vector<pair<int,int> > v;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	for (int i=0;i<5;++i)
	{
		cin>>a[i];
		if (a[i]%10==0) v.pb(mp(0,i));
		else v.pb(mp(10-a[i]%10,i));
	}
	sort(v.begin(),v.end());
	for (int i=0;i<v.size()-1;++i)
	{
		ans+=a[v[i].second];
		if (ans%10!=0) ans=(ans/10+1)*10;
	}
	cout<<ans+a[v[4].second];
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int n;
	int count=0;
	
	while(1){
		scanf("%d", &n);
		
		if(n==0){
			break;
		}
		
		++count;
		
		printf("Case %d: %d\n", count, n); 
	}
	
	return 0;
}

Measured memory_bytes: 2572
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  int L[12];
  for (int i=0; i<N; i++) cin >> L[i];
  sort(L,L+N,greater<int>());
  
  int sum = 0;
  for (int i=1; i<N; i++) {
    sum += L[i];
  }
  if (sum>L[0]) cout << "Yes" << endl;
  
  else cout << "No" << endl;
}


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

namespace ABC046A{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            Console.WriteLine(sr.Next<int>(3).Distinct().Count());
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 3160
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

A = int((2*X-Y)/3)
B = int(X-2*A)

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)


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

int main(){
  int N,K;
  cin >> N >> K;
  int min = 0;
  int x;
  for(int i=0;i<N;i++){
    cin >> x;
    if(x < K-x){
      min += x*2;
    }else{
      min += (K-x)*2;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))
def f(t):
    return t[0] > t[1] and t[1] > t[2] or t[0] < t[1] and t[1] < t[2]
count = 0
for i in range(n - 2):
    if (f(L[i:])):
        count += 1
print(count)

Measured memory_bytes: 3060
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
struct unionfind {
  vector<int> par;
  unionfind(int n) : par(n,-1) {}
  void init(int n) {par.assign(n,-1);}
  int find(int x) {
    if (par[x]<0) return x;
    else return par[x]=find(par[x]);
  }
  bool issame(int x,int y) {
    return find(x)==find(y);
  }
  bool unit(int x,int y) {
    x=find(x),y=find(y);
    if (x==y) return false;
    if (par[x]>par[y]) swap(x, y); 
    par[x]+=par[y];
    par[y]=x;
    return true;
  }
  int size(int x) {
    return -par[find(x)];
  }
};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k,l,p,q,r,s;
  cin >> n >> k >> l;
  unionfind uf1(n),uf2(n);
  for(int i=0; i<k; i++) {
    cin >> p >> q;
    p--,q--;
    uf1.unit(p,q);
  }
  for(int i=0; i<l; i++) {
    cin >> r >> s;
    r--,s--;
    uf2.unit(r,s);
  }
  map<P,int> m;
  for(int i=0; i<n; i++) {
    m[P(uf1.find(i),uf2.find(i))]++;
  }
  for(int i=0; i<n; i++) {
    cout << m[P(uf1.find(i),uf2.find(i))] << " ";
  }
  cout << "\n";
}

Measured memory_bytes: 13568
X,N=map(int,input().split())
P=list(map(int,input().split()))
p=sorted(P)
a=True
if N==0:
    print(X)
    a=False
if (X in p)==False and a==True:
    print(X)
    a=False
if a==True:
    for i in range(1,100):
        if (X-i in p)==False and (X+i in p)==False:
            print(X-i)
            a=False
            break
        elif (X-i in p)==True and (X+i in p)==False:
            print(X+i)
            a=False
            break
        elif (X-i in p)==False and (X+i in p)==True:
            print(X-i)
            a=False
            break

Measured memory_bytes: 61932
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001


int main(){

int n;
scanf("%d",&n);

if(n%10!=((n-n%100)/100))
   printf("No");
else
    printf("Yes");

}


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

int main()
{
    int N;
    int low,tmp;
    scanf("%d", &N);
    scanf("%d", &low);
    int max=-1000000000;
    for (int i = 2; i <= N; i++)
    {
        scanf("%d", &tmp);
        if(tmp-low>max){
            max=tmp-low;
        }
        if(tmp<low){
            low=tmp;
        }
    }
    cout << max << endl;
}



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

double dp[3030][3030];

double get(ll complete, ll i, double a[])
{
    if(i<0)
    {
        if( complete >n/2 ) return 1.0;
        else return 0.0;
    }
    if(dp[complete][i]!=-1) return dp[complete][i];

    double ans =  a[i]*get(complete+1,i-1,a) + (1.0-a[i])*get(complete,i-1,a);
    return dp[complete][i] = ans ;

}

int main() {
    for(ll i=0;i<3030;i++)
    {
        for(ll j=0;j<3030;j++) dp[i][j] = -1;
    }

    cin >> n;
    double a[n];
    for(ll i=0;i<n;i++) cin>> a[i];
    cout << fixed << setprecision(20) << get(0,n-1,a);
}


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

int arr[200005];

int main(){
    #ifdef LOCAL_DEFINE
        freopen("./a.in","r",stdin);
        freopen("./a.out", "w",stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    for (int i=0;i<n-1;i++) {
        int temp;
        cin >> temp;
        arr[temp-1]++;
    }
    for (int i=0;i<n;i++) {
        cout << arr[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4436
n = int(input())
s = input()

if (n % 2 == 1):
    print('No')
else:
    nh = int(n/2)
    #print(nh)
    s1 = s[:nh]
    s2 = s[nh:]
    if s1 == s2:
        print ('Yes')
    else:
        print('No')



Measured memory_bytes: 2940
S = input()
T = input()
lens = len(S)
lent = len(T)
result = lent
cnt = 0

for i in range(0,lens-lent+1):
    for j in range(0,lent):
        if S[i+j] != T[j]:
            cnt = cnt + 1
    if result > cnt:
        result = cnt
    cnt = 0

print(result)


Measured memory_bytes: 9112
#include <stdio.h>

void call(int n)
{
	int i,x;

	for (i = 1; i <= n; i++)
	{
		x = i;
		while (x) {
			if (i % 3 == 0) {
				printf(" %d", i);
				break;
			}
			if (x % 10 == 3) {
				printf(" %d", i);
				break;
			}
			x /= 10;
		}
	}

	printf("\n");

	return;
}

int main(void)
{
	int n;

	scanf("%d",&n);

	call(n);

	return 0;
}


Measured memory_bytes: 2096
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>

using namespace std;
int main(){
    string s;
    cin >> s;
    
    int l=atoi(s.c_str());
    //int head=atoi(s[0])*10+atoi(s[1]);
    //千のくらい

    int back=l%100;
 
    
    int head=(l-back)/100;

    //cout <<back <<endl;
    int b=0;
    int h=0;
    if(back>=1 && back<=12){
        b=1;
    }
    if(head>=1 && head<=12){
        h=1;
    }
    if(b==1 && h==1){
        cout <<"AMBIGUOUS"<<endl;
    }
    else if(b==1 && h==0){
        cout <<"YYMM"<<endl;
    }
    else if(b==0 && h==1){
        cout <<"MMYY"<<endl;
    }
    else{
        cout <<"NA"<<endl;
    }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A + B >= 10) {
      System.out.print("error");
    } else {
      System.out.print(A+B);
    }
   }
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end());
  cout<<A[A.size()-1]-A[0]<<endl;
}


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

int main() {
  string s="";
  int k=0;
  cin>>k>>s;
  
  if(s.size()<=k){
    cout<<s;
  }else{
    rep(i,k){
      cout<<s.at(i);
    }
    cout<<"...";
  }
}

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

int N;

int main(){
    cin >> N;
    N %= 10;
    if(N == 3){
        cout << "bon" << endl;
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
/*
  AUTHOR:SOURABH
  CREATED:10:01:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll n,m,i,p,ans1=0,sum=0;
    string s;
    cin>>n>>m;
    bool f[n+1];
    ll ans2[n+1];
    memset(f,0,sizeof(f));
    memset(ans2,0,sizeof(ans2));
    fn(i,m)
    {
        cin>>p>>s;
        if(f[p]==0)
        {
            if(s=="WA")
                ans2[p]++;
            else
                f[p]=1;
        }
    }
    fs(i,1,n+1)
    {
        if(f[i])
            {ans1++;sum+=ans2[i];}
    }
    cout<<ans1<<" "<<sum;
    return 0;
}








Measured memory_bytes: 1152
N,C = gets.split.map(&:to_i)
D = (0...C).map{ gets.split.map(&:to_i) }
s = [[],[],[]]
N.times { |i|
  gets.split.map(&:to_i).each_with_index{ |a,j| s[(i+j)%3] << a-1 }
}

disco = (0..2).map{ |i|
  (0...C).map{ |c|
    s[i].reduce(0) { |a,d| a += D[d][c] }
  }
}

ans = 1000*N*N
(0...C).to_a.permutation(3) { |cs|
  ans = [ans, (0..2).map{ |i| disco[i][cs[i]] }.inject(:+)].min
}
puts ans

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

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

inline int Pow(int a, int k) {
  int s = 1; 
  for(; k; k >>= 1) {
    k & 1 ? s = 1LL * s * a % MOD : 0;
    a = 1LL * a * a % MOD;
  }
  return s;
}

const int N = 1e6 + 7;

void input() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);
}

void preprocess() {
}

void debug() {
  //  44gg
  if (true) {
  
  }
}



void solve() {
  preprocess();
  // 50gg
  map<char, char> mp;
  mp['T'] = 'A';
  mp['A'] = 'T';
  mp['C'] = 'G';
  mp['G'] = 'C';
  char b;
  cin >> b;
  cout << mp[b] << endl;;
  //debug();
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

void output() {

}

#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false);
	cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  //int t; cin >> t;
  //while (t--) 
  {
    input();
    solve();
    output();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 256
lm,tm=[],[]
while gets.chomp!=""
  lm<<$_.split(",").map(&:to_i)[0]
end
while gets
  tm<<$_.split(",").map(&:to_i)[0]
end
lm.uniq.sort.each do |n|
  puts "#{n} #{(lm+tm).count(n)}" if tm.include?(n)
end

Measured memory_bytes: 8584
// AOJ DSL_3_C The Number of Windows
// 2018.5.6 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in() {
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

long long ll() {
	long long n = 0; int c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF   0x10101010101010LL
#define MAX_N 100005
long long s[MAX_N];

// バイナリサーチ
// x より大きい最初の要素のインデックスを返す。つまり、 > x
int binarySearch(long long x, int N)
{
	int m, l = 1, r = N;

    while (l < r) {
        m = (l+r) >> 1;
        if (s[m] < x) l = m+1; else r = m;
    }
	if (s[l] == x) l++;
	return l;
}

int main()
{
	int N, Q, i, j;
	long long base, x, ans;

	N = in(), Q = in();
	base = (long long)N*(N+1) >> 1;

	for (i = 1; i <= N; i++) s[i] = s[i-1] + in();
	s[++N] = INF;		// caution: N -> N+1

	while (Q--) {
		x = ll();
//		j = 1; while (s[j] <= x) j++;
		j = binarySearch(x, N);
		ans = 0, i = 0;
		while (j < N) {
			while (s[j]-s[i] >  x) i++, ans += N-j;
			while (s[j]-s[i] <= x) j++;
		}
		printf("%lld\n", base-ans);
	}
	return 0;
}


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

namespace ABC098A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, max;
			var word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);

			max = a + b;

			if (max < a - b) max = a - b;
			if (max < a * b) max = a * b;

            Console.WriteLine(max);

			Console.ReadKey();

		}
	} 
}


Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
     public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
    
    }
}

Measured memory_bytes: 26896
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.PG", "r", stdin );
	int n, m, p;
	while (true ){
		scanf ("%d %d %d", &n, &m, &p );
		if ((n | m | p ) == 0 ) break; 
		m--;
		vector<int> x (n, 0 );

		rep (i, n ){
			scanf ("%d", &x[i] );
		} // end rep
		int sum = accumulate(ALL (x), 0 );		// 売上
		int share = sum*(100-p);	// 配当
		int res = 0;
		if (x[m] != 0 ){
			res = share/x[m];
		} // end if
		printf ("%d\n", res );
	} // end loop
		
	return 0;
}

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

int main() {
  int H,W,N;
  int ans = 0;
  cin >> H >> W >> N;
  
  int X = max(H,W);
  ans = N / X;
  
  if (N % X > 0) {
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

int main() {
    SS(ll,n,a,b);
    p((n/(a+b))*a+min(n%(a+b),a));
}

Measured memory_bytes: 256
import java.util.Scanner;

//Integral
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int d = sc.nextInt();
			int s = 0;
			int x = d;
			while(x<600){
				s += d*x*x;
				x+=d;
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
#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 n;
    cin >> n;
    map<int, int> a;

    rep(i, n){
        int ai;
        cin >> ai;
        a[ai] = i+1;
    }

    rep(i, n){
        cout << a.at(i+1);
        if(i<n-1) cout << ' ';
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 8212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int K, X;
    cin >>K>>X;
    int l=-1000000, r=1000000;
    l=max(l, X-(K-1));
    r=min(r, X+(K-1));
    vi ans;
    dump(l,r);
    rep(i, l, r +1){
        ans.pb(i);
    }
    cout << ans << endl;
    return (0^_^0);
}



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

int c[1000001];
char s[1000001];

int main(void){
  int i,j;
  int n,m,ans;

  while(scanf("%d",&n) && n){
    memset(c,0,sizeof(c));

    scanf("%d%s",&m,s);
    for(i=m-1;i>1;i--){
      if(s[i] == 'I' && s[i-1] == 'O' && s[i-2] == 'I'){
        c[i-2] = c[i] + 1;
      }
    }

    ans = 0;
    for(i=0;i<m;i++){
      if(c[i] >= n){
        ans++;
      }
    }
    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

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


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
ll a[N],b[N],c[N],d[N];
int main()
{
    ft
    ll t,i,j,n,m,l,r,s=0,p;
    cin>>n>>m>>l;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for(i=1; i<=m; i++)
    {
        cin>>b[i];
    }
    for(i=1; i<=n; i++)
    {
        c[i]=a[i]+c[i-1];
    }
    for(i=1; i<=m; i++)
    {
        d[i]=b[i]+d[i-1];
    }
    for(i=1; i<=n; i++)
    {
        r=l-c[i];
        if(r>=0)
        {
            p=upper_bound(d+1,d+m+1,r)-d;
            s=max(s,i+p-1);
        }
    }
    for(i=1; i<=m; i++)
    {
        r=l-d[i];
        if(r>=0)
        {
            p=upper_bound(c+1,c+n+1,r)-c;
            s=max(s,i+p-1);
        }
    }
    cout<<s<<"\n";
    return 0;
}



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

int main()
{
  //freopen("in.txt","r",stdin);
   int n;
   cin>>n;
   string ss;
   cin>>ss;
   int ans=0;
   for(int i=0;i<n;i++)
   {
       if(i+2<n)
       {
           if(ss[i]=='A' && ss[i+1]=='B'&& ss[i+2]=='C')
           {
            ans++;
            i=i+2;
           }

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


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

int sort(const void * a, const void * b);

int main(void)
{
	int n[5];
	int i;
	
	for(i = 0;i < 5;i++){
		scanf("%d", &n[i]);
	}
	
	qsort(n,5,sizeof(int),sort);
	
	for(i = 0;i < 4;i++){
		printf("%d ",n[i]);
	}
	
	printf("%d\n",n[4]);
	
	return (0);
}

int sort(const void * a,const void * b)
{
	if(*(int *)a < *(int *)b){
		return 1;
	}
	else if(*(int *)a > *(int *)b){
		return -1;
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int i = 0;
        if(S.charAt(2) == S.charAt(3)) i++;
        if(S.charAt(4) == S.charAt(5)) i++;
        if(i == 2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
# https://atcoder.jp/contests/abc138/tasks/abc138_d

def dfs(lst, start, ans):
    queue = [start]
    visited = [False] * len(ans)
    visited[start] = True

    while queue:
        parent = queue.pop()
        for child in lst[parent]:
            if visited[child]:
                continue
            visited[child] = True
            ans[child] += ans[parent]
            queue.append(child)

    print(*ans)

import sys
input = sys.stdin.readline
n,q = map(int, input().split())
start = 0

tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

ans = [0]*n
for _ in range(q):
    p, x = map(int,input().split())
    ans[p-1] += x
dfs(tree, start, ans)


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

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

  long long ans1=0;
  long long ans2=0;
  long long ans3=0;
  long long ans4=0;

  ans1=a*c;
  ans2=a*d;
  ans3=b*c;
  ans4=b*d;

  cout << max({ans1, ans2, ans3, ans4}) << endl;

return 0;  
}

Measured memory_bytes: 3628
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    A = list(sorted(list(map(int, input().split()))))
    print(A[-1] - A[0])


if __name__ == '__main__':
    main()


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


int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);

    int sum = accumulate(A.begin(), A.end(), 0);
    
    if(sum < H){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, x, ans = 0;
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; i++) {
		for(int j = 0; j <= b; j++) {
			if(x < 500 * i + 100 * j) break;
			if((x - 500 * i - 100 * j) / 50 <= c) ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

if N == 2:
    print(abs(h[1]-h[0]))
else:
    cost = [abs(h[1]-h[0]), abs(h[2]-h[0])]
    newcost = [0,0]

    for i in range(3,N):
        newcost[0] = cost[1]
        newcost[1] = min([cost[0] + abs(h[i-2]-h[i]), cost[1] + abs(h[i-1]-h[i])])
        cost[:] = newcost[:]

    print(cost[1])


Measured memory_bytes: 13928
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 200005
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
#define int long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int po[SIZE];
int cnt[SIZE], ans, now, n, p;
string a;
void sol() {
	if (p % 2 && p % 5) {
		po[0] = 1;
		for (int i = 1; i <= n; i++) {
			po[i] = 10 * po[i - 1] % p;
		}
		cnt[0] = 1;
		for (int i = n - 1; i >= 0; i--) {
			now = now + po[n - 1 - i] * (a[i] - '0') % p;
			now %= p;
			ans += cnt[now];
			cnt[now]++;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if ((a[i] - '0') % p == 0) {
				ans += i + 1;
			}
		}
	}
}
signed main() {
	io(); cin >> n >> p >> a;
	sol();
	cout << ans;
}


Measured memory_bytes: 2196
//It is made by M_sea
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=3000+10;
const int mod=1e9+7;

inline void add(int& x,int y) { x+=y; if (x>=mod) x-=mod; }

int f[N][N][2];

int main() {
    int n=read(),m=read();
    for (re int i=1;i<=n;++i) f[1][i][0]=1;
    f[1][0][1]=1;
    for (re int i=1;i<=m;++i)
        for (re int j=0;j<=n;++j) {
            if (j>=1) {
                if (j==1) add(f[i+1][j-1][1],f[i][j][0]);
                else add(f[i+1][j-1][0],f[i][j][0]);
                add(f[i+1][j-1][1],f[i][j][1]);
            }
            if (j<n) {
                add(f[i+1][j+1][0],f[i][j][0]);
                add(f[i+1][j+1][1],f[i][j][1]);
            }
            if (j>=1) {
                if (j==1) add(f[i+1][j][1],f[i][j][0]);
                else add(f[i+1][j][0],f[i][j][0]);
                add(f[i+1][j][1],f[i][j][1]);
            }
            if (j<n) {
                add(f[i+1][j][0],f[i][j][0]);
                add(f[i+1][j][1],f[i][j][1]);
            }
        }
    int ans=0;
    for (re int i=0;i<=n;++i) add(ans,f[m+1][i][1]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    int kai=0,nai=0,mai=0,ans=0;
    rep(i,n-1){
        if(mai==1){
            mai=0;
            continue;
        }
        if(a[i]==a[i+1]){
            ans++;
            mai=1;
            if(ans==1){
                kai=a[i];
            }
            else{
                nai=a[i];
            }
        }
        if(ans==2){
            break;
        }
    }
    cout<<kai*nai<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
int n, k, ans;
int t[210000];
int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		t[x]++;
	}
	sort(t + 1, t + n + 1);
	for (int i = 0; i < k; i++)
		ans += t[n - i];
	ans = n - ans;
	printf("%d\n", ans);
	return 0;
}

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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        n = int(lines[0])
        for i in range(n):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        n = int(lines[0])

    sp = []
    for i in range(1, n+1):
        token = lines[i].split()
        s = token[0]
        p = int(token[1])
        sp.append((s, p, i))

    return (n, sp)


def solve(n, sp):

    sp2 = [(e[0], -e[1], e[2]) for e in sp]
    sp2.sort()
    for e in sp2:
        print(e[2])


def main():
    # 出力

#    print("%s" % solve(*parse_input()))

    solve(*parse_input())

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  int ans[n] = {0};
  int a;
  for(int i = 1; i <= n; i++){
    for(int j = i+1; j <= n; j++){
      a = min(j-i,abs(x-i)+abs(y-j)+1);
      a = min(a,abs(x-j)+abs(y-i)+1);
      ans[a]++;
    }
  }
  for(int i = 1; i < n; i++){
    printf("%d\n", ans[i]);
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using P = pair<int, int>;

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

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

    cout << a * b / gcd(a, b) << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  vector<vector<int>> vec(N,vector<int>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
  }
  int MINF = -10000;
  int dp1[N+1][T+1];
  int dp2[N+1][T+1];
  for(int i=0; i<N+1; i++){
    for(int j=0; j<T+1; j++){
      dp1[i][j] = 0;
      dp2[i][j] = 0;
    }
  }
  
  for(int i=0; i<N; i++){
    int a = vec.at(i).at(0);
    int b = vec.at(i).at(1);
    //dp1[i+1][a] = max(dp1[i+1][a],b);
    for(int j=0; j<T+1; j++){
      int x = MINF;
      if(j - a >= 0){
        x = dp1[i][j-a];
      }
      dp1[i+1][j] = max({dp1[i+1][j], dp1[i][j], x + b});
    }
  }
  
  
  for(int i=0; i<N; i++){
    int a = vec.at(N-i-1).at(0);
    int b = vec.at(N-i-1).at(1);
    //dp2[i+1][a] = max(dp2[i+1][a],b);
    for(int j=0; j<T+1; j++){
      int x = MINF;
      if(j - a >= 0){
        x = dp2[i][j-a];
      }
      dp2[i+1][j] = max({dp2[i+1][j], dp2[i][j], x + b});
    }
  }
  
  /*for(int i=0; i<N+1; i++){
    for(int j=0; j<T+1; j++){
      cout << dp1[i][j] << " ";
    }
    cout << endl;
  }*/
  
  
  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<T; j++){
      ans = max(ans,dp1[i][j] + dp2[N-i-1][T-j-1] + vec.at(i).at(1));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 70784
#!/usr/bin/perl
use Data::Dumper;

my ($n,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @A = map { $_ - 0 } split(/\s+/,<STDIN>);

for(my $i=$k;$i<$n;$i++){
  # prev = $i-$k .. $i-1 
  # cur =  $i-($k-1) .. $i
  my $r = 'No';
  $r = 'Yes' if( $A[$i] > $A[$i-$k] );
  print "$r\n";
  
}





Measured memory_bytes: 39488
#coding:utf-8
import itertools

N = int(input())
li = []
lasta = 0
firstb = 0
ab = 0
cnt = 0

# 各入力のABの数を求める
# HeadにBもしくはTailにAを持つリストをカウント
for i in range(N):
    s = input()
    cnt += s.count('AB')
    li = list(s)
    if li[-1] == 'A' and li[0] != 'B':
        lasta += 1
    if li[0] == 'B' and li[-1] != 'A':
        firstb += 1
    if li[-1] == 'A' and li[0] == 'B':
        ab += 1


# print('lasta : %d firstb : %d ab : %d cnt : %d' % (lasta, firstb, ab, cnt))
if ab == 0:
    cnt += min(lasta,firstb)
elif ab != 0 and lasta + firstb > 0:
    cnt += ab + min(lasta, firstb)
elif ab != 0 and lasta + firstb == 0:
    cnt += ab - 1

print(cnt)


Measured memory_bytes: 3064