akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

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

    int n, k;
    cin >> n >> k;
    mint ans = 0;
    for (int i = k; i <= n+1; ++i) {
        ans += 1LL * (n - i + 1) * i + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(void){
	int n,a[201],i,cnt=-1,flag=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	while(flag==1){
		for(i=0;i<n;i++){
			if(a[i]%2==1)flag=0;
			a[i]/=2;
		}
	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int main(void)
{
    while(1){
        int n, m;
        scanf(" %d %d", &n, &m);
        if(n == 0 && m == 0)
            break;
        int taro[n];
        int hanako[m];
        for(int i = 0; i < n; i++)
            scanf(" %d", &taro[i]);
        for(int i = 0; i < m; i++)
            scanf(" %d", &hanako[i]);
        int mi = 1000000000;
        int t_ans, h_ans;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                swap(taro[i], hanako[j]);
                int t_sum = 0, h_sum = 0;
                for(int k = 0; k < n; k++)
                    t_sum += taro[k];
                for(int k = 0; k < m; k++)
                    h_sum += hanako[k];
                //printf("%d %d\n", t_sum, h_sum);
                if(h_sum == t_sum){
                    if(mi > taro[i] + hanako[j]){
                        mi = taro[i] + hanako[j];
                        t_ans = hanako[j];
                        h_ans = taro[i];
                     }
                }

                swap(taro[i], hanako[j]);
            }
        }
        if(mi != 1000000000)
            printf("%d %d\n", t_ans, h_ans);
        else
            printf("-1\n");
    }


    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e5+4;
ll dp[200][M],w[200],v[200],ans=0;
int main()
{
	int N,W;
	cin>>N>>W;
	for(int i=1;i<=N;i++) cin>>w[i]>>v[i];
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<=W;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=w[i])
			dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans;
	return 0;
}

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

string N,out_moji;
double x,T,A,AA,Z,ZZ;        

int main() {
    cin >> N;
    x = N.size();
    AA = 0;
    ZZ = 0;
        for (int i = 0; i < x; i = ++i) {        
          if(N[i] == 'A' && AA == 0) {
          A = i;
          AA = 1;
          }          
          if(N[i] == 'Z'){
          Z = i;
          ZZ = 1;
          } 
          // out_moji = out_moji + N[i];  
          //cout << i << endl;     
        }
        // for (A; A < Z; A++) {      
        //     //cout << A << endl;
        //   out_moji = out_moji + N[A];       
        // }


      
    // cout << max << endl;
   //  cout << min << endl;
   // max = max - min;
    cout << Z - A + 1 << endl;
}

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

int main(){
  int n,min,count=0,countmin=0,countmax=0,k=0;
  cin >> n;
  vector<int> w(n),sa(n-1);
  rep(i,n){
    cin >>w[i];
  }
  rep(i,n){
    count+=w[i];
  }
  rep(i,n-1){
    rep1(j,i+1,n){
      countmax+=w[j];
    }
    countmin=count-countmax;
    sa[i]=countmax-countmin;
    countmax=0;
    countmin=0;
  }
  while(sa[k]>0){
    k++;
  }
  if(k>0 && k<n-2)
    cout << std::min(sa[k-1],-sa[k]);
  else if(k==0)
    cout << sa[0];
  else if(k==n-2)
    cout << sa[n-2];
}

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

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

int concat_ints(int a, int b) {
    int places = count_places(b);
    int m = 1;
    while (places > 0) {
        m *= 10;
        --places;
    }

    while (a > 0) {
        int r = a % 10;
        a /= 10;
        b += (r * m);
        m *= 10;
    }

    return b;
}

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

    int a, b;
    cin >> a >> b;
    int n = concat_ints(a, b);
    int s = sqrt(n);
    cout << (s * s == n ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 3660
import Control.Applicative
import Data.List
main = solve

solve = do
    n <- readLn :: IO Int
    ns <- fmap (read :: String -> Int) . words <$> getLine
    let min = minimum ns
        max = maximum ns
        amount = sum ns
    putStrLn $ (show min) ++ " " ++ (show max) ++ " " ++ (show amount)

Measured memory_bytes: 11376
#include <iostream>
#include <cassert>
#include <string>
using namespace std;

/*
Digit := '0' | '1' | ... | '9'
Number := Digit { Digit }
Expression := Term { ('+'|'-') Term }
Term := Factor { ('*'|'/') Factor }
Factor := '(' Expression ')' | Number
*/

string S;
size_t cur=0;

int digit();
int number();
int expression();
int term();
int factor();

int digit(){
    assert(isdigit(S[cur]));
    int n=S[cur]-'0';
    cur++;

    return n;
}

int number(){
    int n=digit();
    while(cur<S.length() && isdigit(S[cur]))
        n=n*10+digit();
    
    return n;
}

int expression(){
    int n=term();
    while(cur<S.length() && (S[cur]=='+' || S[cur]=='-')){
        if(S[cur]=='+'){
            cur++;
            n=n+term();
        }else{
            cur++;
            n=n-term();
        }
    }

    return n;
}

int term(){
    int n=factor();
    while(cur<S.length() && (S[cur]=='*' || S[cur]=='/')){
        if(S[cur]=='*'){
            cur++;
            n=n*factor();
        }else{
            cur++;
            n=n/factor();
        }
    }

    return n;
}

int factor(){
    if(S[cur]=='('){
        cur++;
        int n=expression();
        assert(S[cur]==')');
        cur++;

        return n;
    }else{
        return number();
    }
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cur=0;
        cin >> S;
        S.resize(S.length()-1);

        cout << expression() << endl;
    }

    return 0;
}

Measured memory_bytes: 3172
import sys
input=sys.stdin.readline
N = int(input())
S = input()
int_s = [0] * N
cum_sum_w = [0] * (N + 1)
cum_sum_e = [0] * (N + 1)
answers = [0] * N
for i in range(N):
    if (S[i] == 'W'):
        int_s[i] = 1
    else:
        int_s[i] = 0
    cum_sum_w[i + 1] = cum_sum_w[i] + int_s[i]
for i in range(N):
    if (S[i] == 'E'):
        int_s[i] = 1
    else:
        int_s[i] = 0
    cum_sum_e[i + 1] = cum_sum_e[i] + int_s[i]
for i in range(N):
    answers[i] = cum_sum_w[i] + (cum_sum_e[N] - cum_sum_e[i + 1])
print(min(answers))

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

int main(){
	int c, b;
	scanf("%d", &c);
	scanf("%d", &b);
	int a[4];
	a[1]=a[2]=a[3]=0;
	a[c]=a[b]=1;
	if(a[1]==0)
		printf("1\n");
	else if(a[2]==0)
		printf("2\n");
	else printf("3\n");
	return 0;
}

Measured memory_bytes: 256
def main():
    sx,sy,tx,ty=map(int,input().split())
    s=(sx,sy)
    t=(tx,ty)
    dif_y = abs(ty-sy)
    dif_x = abs(tx-sx)
    ans = "U"*dif_y+"R"*dif_x
    ans += "D"*dif_y+"L"*dif_x
    ans += "L"+"U"*(dif_y+1)+"R"*(dif_x+1)+"D"
    ans += "R"+"D"*(dif_y+1)+"L"*(dif_x+1)+"U"
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	int n;
	cin >> n;
	int mn = 1000;
	int mx = 0;
	ff(i, 0, n) {
		int a;
		cin >> a;
		mx = max(mx, a);
		mn = min(mn, a);
	}
	cout << mx - mn << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, = read_h()
    A = read_h()

    if len(A) == 1:
        print(1)
        return

    cnt = 1
    inc = None

    for i in range(len(A) - 1):
        #  print(A[i:i + 2])

        if inc is None and A[i] != A[i + 1]:
            inc = A[i] < A[i + 1]
            continue

        if A[i] == A[i + 1] or (inc and A[i] < A[i + 1]) or (not inc and A[i] > A[i + 1]):
            continue

        #  print('change')
        cnt += 1
        inc = None

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14484
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

constexpr int inf = 1e9 + 7;

bool Out(int n, map<int, bool>& mp) {
    while (n != 0) {
        int b = n % 10;
        n /= 10;
        if (mp[b]) return true;
    }

    return false;
}

int main() {

    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    map<int, bool> mp;
    for (int i = 0; i < k; ++i) {
        cin >> d[i];
        mp[d[i]] = true;
    }

    int ans = n;

    while (Out(ans, mp)) {
        ++ans;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
	map<char, char> m1, m2;
	string s, t;
	char c1 = 'A', c2 = 'A';
	cin >> s >> t;
	for(char c = 'a'; c <= 'z';c++)
		m1[c] = '@', m2[c] = '@';
	for(int i=0;i<s.size();i++) {
		if(m1[s[i]] == '@') {
			m1[s[i]] = c1;
			s[i] = c1;
			c1++;
		} else {
			s[i] = m1[s[i]];
		}
		if(m2[t[i]] == '@') {
			m2[t[i]] = c2;
			t[i] = c2;
			c2++;
		} else {
			t[i] = m2[t[i]];
		}
	}
	if(s == t) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> psum(n+2);
	vector<vector<ll>> v(n+2,vector<ll>(n+2));
	for (int i=1; i<=n; ++i){
		cin >> v[1][i];
		psum[i] = psum[i-1] + v[1][i];
	}
	for (int h=2; h<=n; ++h){
		for (int b=1; b<=n-h+1; ++b){
			int e=b+(h-1);
			v[h][b]=(psum[e]-psum[b-1])-min(v[h-1][b],v[h-1][b+1]);
		}
	}
	cout << 2*v[n][1]-psum[n];
	return 0;
}

Measured memory_bytes: 70784
def move(d, r):
    if r == 'N':
        return (d[1], d[5], d[2], d[3], d[0], d[4])
    if r == 'E':
        return (d[3], d[1], d[0], d[5], d[4], d[2])
    if r == 'W':
        return (d[2], d[1], d[5], d[0], d[4], d[3])
    if r == 'S':
        return (d[4], d[0], d[2], d[3], d[5], d[1])
    return d
     
dice_1 = tuple(map(str,input().split()))
dice_2 = tuple(map(str,input().split()))

def gen_all(dice_1):
    dice = {dice_1}
    while True:
        dice2 = {move(d,r) for d in dice for r in list("NEWS")}.union(dice)
        if dice == dice2: break
        dice = dice2
    return dice    

print("Yes" if dice_2 in gen_all(dice_1) else "No")
    
    
    

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

ll floor_sum(ll n, ll m, ll a, ll b) {
    ll ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    ll y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main(){
  int t; cin>>t;
  while(t--){
    ll n,m,a,b; cin>>n>>m>>a>>b;
    cout << floor_sum(n,m,a,b) << endl;
  }
  return 0;
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long sum = accumulate(a.begin(), a.end(), 0ll);
  for (int i = n - 2; i >= 0; --i) {
    sum -= a[i + 1];
    if (sum * 2 < a[i + 1]) {
      cout << n - i - 1 << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if (c=='a')
    cout << "vowel" << endl;
  else if (c=='i')
    cout << "vowel" << endl;
  else if (c=='u')
    cout << "vowel" << endl;
  else if (c=='o')
    cout << "vowel" << endl;
  else if (c=='e')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
i=61,f[],c,m,s;main(y){for(;~s?++f[y*12+*f+"=>?2J13IK<@V&"[1+--s]]:~scanf("%d,%d,%d",f,&y,&s)?s*=4:++i<180?i%12>1?(y=f[i])?y>m?m=y:1:++c:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//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 F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int N, M;
int adj[15][15], stor[1<<15][15], dp[1<<15][15];
vector<pii> nex[1<<15];

void gen(int i, int cur, int todo, int cost) {
    if (todo == N) {
        nex[i].pb({cur,cost});
        return;
    }    
    if ((i & (1<<todo)) == 0) gen(i,cur+(1<<todo),todo+1,cost+stor[i][todo]);
    gen(i,cur,todo+1,cost);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    F0R(i,M) {
        int a,b,c; cin >> a >> b >> c;
        a--, b--;
        adj[a][b] = adj[b][a] = c;
    }
    
    F0R(i,1<<N) {
        F0R(j,N) {
            int tot = 0;
            F0R(k,N) if (i & (1<<k)) tot += adj[j][k];
            stor[i][j] = tot;
        }
        gen(i,0,0,0);
    }
    
    F0R(i,1<<N) F0R(j,N) dp[i][j] = MOD;
    dp[1][0] = 0;
    
    F0R(i,1<<N) if (i&1) F0R(j,N) if (i&(1<<j)) {
        F0R(k,N) if ((i&(1<<k)) == 0) if (adj[j][k]) dp[i^(1<<k)][k] = min(dp[i^(1<<k)][k],dp[i][j]+stor[i^(1<<j)][k]);
        for(pii a: nex[i]) dp[i^a.f][j] = min(dp[i^a.f][j],dp[i][j]+a.s-stor[a.f][j]);
    }
    
    cout << dp[(1<<N)-1][N-1];
}

Measured memory_bytes: 117500
n,m=map(int,input().split())
lists=[0 for i in range(m)]
for i in range(m):
    x,y=map(int,input().split())
    lists[i]=(x,y)
anslist=[0 for i in range(n+1)]
#anslist[1] からanslist[n]まででこれらが全て偶数となるような時を考えればいい
#そうでないならばそれはNoである
for j in lists:
    if j[0]==1:
        anslist[j[1]]+=1
        
    elif j[1]==1:
        anslist[j[0]]+=1
        
    else:
        x=j[0]
        y=j[1]
        anslist[x]+=1
        anslist[y]+=1
flag=True
for k in anslist:
    if k%2!=0:
        flag=False
        break
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 17428
# ARC084C - Snuke Festival
from bisect import bisect_left, bisect_right

def main():
    n = int(input())
    A, B, C = [sorted(tuple(map(int, input().rstrip().split()))) for _ in range(3)]
    l, ans = len(C), 0
    for i in B:
        ans += bisect_left(A, i) * (l - bisect_right(C, i))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 22720
program main
      read(*,*) i, j, k
      if (abs(i - j) .lt. abs(i-k)) then
            write(*,*) "A"
      else
            write(*,*) "B"
      end if
      end

      function abs(a)
      integer abs, a
      if (a > 0) then
            abs = a
      else
            abs = -1 * a
      end if
      end function

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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 rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    int x[n],y[n],h[n];
    rep(i,n){
        cin>>x[i]>>y[i]>>h[i];
    }
    int tmp;
    rep(j,101){
        rep(k,101){
            bool che=true;
            bool ans=false;
            rep(l,n){
                if(che&&h[l]>=1){tmp=h[l]+abs(x[l]-j)+abs(y[l]-k);che=false;ans=true;}
                else{
                    if(h[l]==0||tmp==h[l]+abs(x[l]-j)+abs(y[l]-k))continue;
                    else {ans=false; break;}
                }
            }
                if(ans){
                    int c=true;
                    rep(m,n){
                        if(h[m]==0){
                            if(tmp-abs(x[m]-j)-abs(y[m]-k)<=0)continue;
                            else {c=false;break;}
                        }
                    }
                    if(c){cout<<j<<" "<<k<<" "<<tmp<<endl;
                        return 0;
                        }
                }
        }
    }
    return 0;
}




Measured memory_bytes: 256
n, x, y = map(int, input().split())

a = [0]*(n-1)
for i in range(n):
    for j in range(n):
        if i < j:
            dis1 = j-i
            dis2 = abs(x-1-i)+abs(y-1-j)+1
            dis = min(dis1, dis2)
            a[dis-1] += 1
            #print(i,j,dis1,dis2,dis)
for i in a:
    print(i)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
const int MAXN=110;
int tot,head[MAXN];
struct Edge {int to,net;}E[MAXN<<1];
void addedge(int x,int y)
{
	E[++tot].to=y;E[tot].net=head[x];head[x]=tot;
	E[++tot].to=x;E[tot].net=head[y];head[y]=tot;
}
long long Ans,Pow[MAXN];
int depth[MAXN],fa[MAXN];
int N,M,A[MAXN],B[MAXN];
int Cnt[MAXN];
void dfs(int x)
{
	for (int i=head[x];i;i=E[i].net)
		if (E[i].to!=fa[x])
		{
			fa[E[i].to]=x;
			depth[E[i].to]=depth[x]+1;
			dfs(E[i].to);
		}
}
void solve(int x,int y,int v)
{
	while (x!=y)
	{
		if (depth[x]<depth[y]) swap(x,y);
		Cnt[x]+=v;
		x=fa[x];
	}
}
void dfs2(int x,int cnt)
{
	if (x==M+1)
	{
		int sum=0;
		for (int i=2;i<=N;++i)
			if (!Cnt[i])
				sum++;
		if (cnt&1) Ans-=Pow[sum];
		else Ans+=Pow[sum];
		return ;
	}
	solve(A[x],B[x],1);
	dfs2(x+1,cnt+1);
	solve(A[x],B[x],-1);
	dfs2(x+1,cnt);
}
int main()
{
	Pow[0]=1;
	for (int i=1;i<50;++i) Pow[i]=Pow[i-1]*2;
	cin>>N;
	for (int i=1;i<N;++i)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		addedge(a,b);
	}
	dfs(1);
	cin>>M;
	for (int i=1;i<=M;++i) cin>>A[i]>>B[i];
	dfs2(1,0);
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import sys

N = int(input())

d = list(map(int, input().split()))

d.sort()

b = (N+1) // 2
a = b - 1

d1 = d[a]
d2 = d[b]

if d1 == d2:
    print(0)
    sys.exit()

print(d2 - d1)


Measured memory_bytes: 14396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPowerSocket solver = new BPowerSocket();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPowerSocket {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int ans = 0;
            int act = 1;
            while (act < b) {
                ans++;
                act--;
                act += a;
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <limits>

using ll = long long;
using namespace std;
int gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}
int main(){
    ll n,a,b;
    cin >>n >>a >> b;
    if(a>b){
        cout<<0<<endl;
        return 0;
    }
    if(a==b){
        cout<<1<<endl;
        return 0;
    }
    if(n==1){
        if(a!=b){
            cout<<0<<endl;
            return 0;
        }else{
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<setprecision(50)<<(b-a)*(n-2)+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=s[i];
    }
    if(0==sum%10){
        for(int i=0;i<n;i++){
            if(0!=s[i]%10){
                cout<<sum-s[i]<<endl;
                return 0;
            }
        }
        cout<<0<<endl;
    }else{
        cout<<sum<<endl;
    }
    return 0;
    
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

vector<string> day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep (i, day.size())
        if (day[i] == s) print(7 - i);

    return 0;
}


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

using namespace std;

int main()
{
	vector<int> ans;
	stack<int> st;
	ans.clear();
	while(!st.empty()) st.pop();
	static bool used[20020];
	memset(used,false,sizeof(used));
	int t=0,tot=0;
	static char str[20020];
	scanf("%s",str);
	for(int i=0;str[i]!=0;i++)
		if(str[i]=='\\') st.push(i);
		else if(str[i]=='/'&&!st.empty()) st.pop();
	while(!st.empty())
	{
		used[st.top()]=true;
		st.pop();
	}
	for(int i=0;str[i]!=0;i++)
		if(str[i]=='\\'&&!used[i]) st.push(i);
		else if(str[i]=='/'&&!st.empty()) 
		{
			t+=i-st.top();
			st.pop();
			if(st.empty())
			{
				tot+=t;
				ans.push_back(t);
				t=0;
			}
		}
	printf("%d\n",tot);
	printf("%d%c",ans.size(),ans.size()==0?'\n':' ');
	for(int i=0;i<ans.size();i++)
		printf("%d%c",ans[i],i+1==ans.size()?'\n':' ');
	return 0; 
}

Measured memory_bytes: 3344
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


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

char input[1025];
char g[]=".,!? abcdefghijklmnopqrstuvwxyz";
int h[]={5,3,3,3,3,3,4,3,4};
int k[10];


int main(){
	while(1){
		int n,ret=0;
		cin>>n;
		if(n==0)return 0;
		for(int i=1; i<=n/2; i++){
			for(int j=i+1; j*(j+1)/2-i*(i-1)/2<=n;j++){
				if(j*(j+1)/2-i*(i-1)/2==n){
					ret++;
					break;
				}
			}
		}
		cout << ret << endl;
	}
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define f first
#define s second
#define endl '\n'
#define mp make_pair
#define watch(x) cout << (#x) << " is " << (x) << endl;

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

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    int n; cin >> n;
    if(n==7 or n==5 or n==3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
#define pb push_back
#define INF 1e5
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    
    int x;
    cin>>x;
    int moves=0,ans=0;
    moves=(x/500);
    ans+=moves*1000;
    x-=(moves*500);
    moves=x/5;
    ans+=moves*5;
    cout<<ans<<"\n";
    return 0;
}

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

int main()
{
  int n; cin >> n;
  for (int i=1; i<=9; i++) {
    if (n%i==0 && n/i<=9) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    int c[h*w], cnt=0;
    for(int i=1; i<=n; i++){
        int a;
        cin >> a;
        for(int j=0; j<a; j++) c[cnt+j]=i;
        cnt+=a;
    }

    int place=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(i%2==0) cout << c[place+j] << " ";
            else cout << c[place+w-1-j] << " ";
        }
        cout << endl;
        place+=w;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    int num[10][10];//先頭-末尾
    For(i,0,10) For(j,0,10) num[i][j]=0;
    For(i,1,n+1){
        ll head,tail;
        tail=i%10;
        if(tail==0) continue;
        int keta=i;
        while(keta/10>0) keta/=10;
        head=keta;
        num[head][tail]++;
    }
    For(i,1,10){
        For(j,1,10){
            ans+=num[i][j]*num[j][i];
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(100);

  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }

  int m;
  cin >> m;
  vector<string> t(100);
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    int c = 0;
    for(int j = 0; j < n; j++){
      if(s.at(i) == s.at(j)){
        c++;
      }
    }
    int d = 0;
    for(int j = 0; j < m; j++){
      if(s.at(i) == t.at(j)){
        d++;
      }
    }

    ans = max(ans, c - d);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  /*vector<int> posR, posL;
  for(int i = 0; i < N; i++){
    if(s[i] == 'R') posR.push_back(i);
    else posL.push_back(i);
  }*/

  int cnt[N];
  fill(cnt, cnt + N, 0);

  int posL = 0;
  int posR = 0;

  for(int i = 0; i < N - 1; i++){
    if(s[i] == 'R' && s[i + 1] == 'L'){
      posL = i + 1;
      while(posL < N - 1 && s[posL + 1] == 'L') posL++;
      int cntL = posL - i;
      cnt[i] += cntL / 2;
      cnt[i + 1] += cntL - (cntL / 2);
      int cntR = i - posR + 1;
      cnt[i + 1] += cntR / 2;
      cnt[i] += cntR - (cntR / 2);
    }
    else if(s[i] == 'L' && s[i + 1] == 'R'){
      posR = i + 1;
    }
  }

  for(int i = 0; i < N; i++){
    cout << cnt[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int a[1001];
int b[1001];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N,X,T;
    cin>>N>>X>>T;
    int res = ceil(1.0*N/X)*T;
    cout<<res;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
#define enld endl

int main(){
    int a,b,c,n,m,k,d;
    string s;
    cin>>n>>d;
    a=d*2+1;
    cout<<n/a+min(1,n%a)<<endl;

}

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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const long long N = (long long) 1e6 + 5;
const long long mod = (long long) 1e9 + 7;

int n,m,q,color[N],v[N],d[N],c[N],u[N],x,y,di[N];
vector<int> g[N];

void dfs(int vv,int dd,int cc,int dist){
        if(di[vv] >= dist)
                return;
        if(!color[vv])
                color[vv] = cc;
        u[vv] = 1;
        di[vv] = dist;

        for(auto to : g[vv]){
                if(!u[to]){
                        dfs(to,dd,cc,dist - 1);
                }
        }
        u[vv] = 0;
}
int main () {
        scanf("%d%d", &n,&m);

        for(int i = 1; i <= m; i ++){
                scanf("%d%d", &x,&y);
                g[x].pb(y);
                g[y].pb(x);
        }
        memset(di,-1,sizeof(di));
        cin >> q;

        for(int i = 1; i <= q; i ++)
                scanf("%d%d%d",&v[i],&d[i],&c[i]);

        for(int i = q; i >= 1; i --){
                dfs(v[i],d[i],c[i],d[i]);
        }
        for(int i = 1; i <= n; i ++)
                cout << color[i] << endl;
        return 0;
}


Measured memory_bytes: 43000
# セグ木のパフォーマンステスト

class SegmentTree(object):
    __slots__ = ["elem_size", "tree", "default", "op"]

    def __init__(self, a, default, op):
        self.default = default
        self.op = op
        if hasattr(a, "__iter__"):
            real_size = len(a)
            self.elem_size = elem_size = 1 << (real_size-1).bit_length()
            self.tree = tree = [default] * (elem_size * 2)
            tree[elem_size:elem_size + real_size] = a
            for i in range(elem_size - 1, 0, -1):
                tree[i] = op(tree[i << 1], tree[(i << 1) + 1])
        elif isinstance(a, int):
            real_size = a
            self.elem_size = elem_size = 1 << (real_size-1).bit_length()
            self.tree = [default] * (elem_size * 2)

    def get_value(self, x: int, y: int) -> int:  # 半開区間
        l, r = x + self.elem_size, y + self.elem_size
        tree, result, op = self.tree, self.default, self.op
        while l < r:
            if l & 1:
                result = op(tree[l], result)
                l += 1
            if r & 1:
                r -= 1
                result = op(tree[r], result)
            l, r = l >> 1, r >> 1
        return result

    def set_value(self, i: int, value: int) -> None:
        k = self.elem_size + i
        self.tree[k] = value
        self.update(k)

    def update(self, i: int) -> None:
        op, tree = self.op, self.tree
        while i > 1:
            i >>= 1
            tree[i] = op(tree[i << 1], tree[(i << 1) + 1])


from operator import itemgetter

N, M = map(int, input().split())
LRC = [list(map(int, input().split())) for _ in range(M)]
LRC.sort(key=itemgetter(0))

idx_LRC = 0
q = []

seg = SegmentTree(N+1, float("inf"), min)

seg.set_value(1, 0)
for v in range(1, N + 1):
    d = seg.get_value(v, N + 1)
    while idx_LRC < M:
        l, r, c = LRC[idx_LRC]
        if l <= v:
            seg.set_value(r, min(seg.tree[r + seg.elem_size], d + c))
            idx_LRC += 1
        else:
            break
ans = seg.tree[N + seg.elem_size]
print(ans if ans != float("inf") else -1)


Measured memory_bytes: 107604
#include <iostream>
#include <unordered_map>

using namespace std;

int main()	{
  int n;
  cin >> n;
  int a[n] = {0};
  unordered_map<int, int> count;
  for (int i = 0; i < n; i++)	{
    cin >> a[i];
    count[a[i]]++;
    count[a[i] - 1]++;
    count[a[i] + 1]++;
  }
  int max = -2;
  for (auto it = count.begin(); it != count.end(); it++)	{
    if ((*it).second > max)
      max = (*it).second;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void item()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d%2==0)
    {
            int cnt=0;
            if(a%2==0)
            cnt++;
            if(b%2==0)
            cnt++;
            if(c%2==0)
            cnt++;
            if(cnt>=2||cnt==0)
            {
                    cout<<"YES\n";
                    return ;
            }
            else
            {
                    cout<<"NO\n";
                    return;
            }
    }
    else
    {
            int cnt=0,k=min(a,min(b,c));
            if(a%2!=0)
            cnt++;
            if(b%2!=0)
            cnt++;
            if(c%2!=0)
            cnt++;
            if((cnt>=2&&k!=0)||cnt==0)
            {
                    cout<<"YES\n";
                    return ;
            }
            else
            {
                    cout<<"NO\n";
                    return;
            }
    }
}
int main() {
        
	string a;
  cin>>a;
  int cnt=0,flag=0;
  for(int i=1;i<a.size();i++)
  {
    if(a[i]=='R'&&a[i-1]=='R')
    {cnt++;flag=1;}
  }
    if(a.find('R')==string::npos&&flag==0)
    {cout<<0<<"\n";return 0;}
  cout<<++cnt;
}


Measured memory_bytes: 3628
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); 
var xs = input.trim().split('\n').slice(1).map(function(x){ return x.split(' '); }); 
var ys = {};
xs.forEach(function(x){
    if(x[0] === 'insert'){
        ys[x[1]] = true;
    }else if(x[0] === 'find'){
        console.log(ys.hasOwnProperty(x[1]) ? 'yes' : 'no');
    }
});


Measured memory_bytes: 405772
n = int(input())
h = [int(i) for i in input().split()]
# print(n)
# print(h)
dp = [-1]*n
for i in range(n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = dp[i-1]+abs(h[i-1]-h[i])
    else:
        dp[i] = min([dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])])
# print(dp)
print(dp[n-1])


Measured memory_bytes: 13980
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    vector<string> S(3);

    cin >> S[0] >> S[1] >> S[2];

    char tmp;
    ll i = 0, j = 0, k = 0;

    tmp = S[0][i];

    while (1) {
        if (tmp == 'a') {
            tmp = S[0][i];
            i++;
            if (i > S[0].size()) {
                cout << 'A';
                break;
            }
            
        }
        else if (tmp == 'b') {
            tmp = S[1][j];
            j++;
            if (j > S[1].size()) {
                cout << 'B';
                break;
            }
            
        }
        else if (tmp == 'c') {
            tmp = S[2][k];
            k++;
            if (k > S[2].size()) {
                cout << 'C';
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3132
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
		long first = calcFirst(A);
		List<Long> results = calc(A, first);
		showResult(results);
		in.close();
	}

	static void showResult(List<Long> results) {
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append(Long.toString(results.get(0)));
		for (int i = 1; i < results.size(); ++i) {
			strBuilder.append(" " + Long.toString(results.get(i)));
		}
		System.out.println(strBuilder.toString());
	}

	static List<Long> calc(long[] A, long first) {
		List<Long> result = new ArrayList<>();
		result.add(first);
		for (int i = 1; i < A.length; ++i) {
			long prev = result.get(i - 1) / 2;
			long next = (A[i - 1] - prev) * 2;
			result.add(next);
		}
		return result;
	}

	static long calcFirst(long[] A) {
		long result = 0;
		for (int i = 0; i < A.length; ++i) {
			if (i % 2 == 0) {
				result += A[i];
			} else {
				result -= A[i];
			}
		}
		return result;
	}

}


Measured memory_bytes: 51580
import bisect
n,m = map(int,input().split())
a = m//n

anslist = []
for i in range(1,int(m**0.5)+2):
    if m%i==0:
        anslist.append(i)
ansl = anslist.copy()
ansl.reverse()
for i in ansl:
    anslist.append(m//i)
    
anslist = list(set(anslist))
anslist.sort()
pos = bisect.bisect_left(anslist,n)
print(m//anslist[pos])

Measured memory_bytes: 3188
S = input()
ans = 0
for s in range(len(S)):
	if S[s]=="R":
		ans += 1

if ans == 3:
    print(3)
elif ans == 1:
    print(1)
elif ans == 0:
    print(0)
else:
    if S[1] == "S":
        print(1)
    else:
        print(2)





Measured memory_bytes: 61616
N = int(input())
left  =  [-1 for i in range(N)]
right =  [-1 for i in range(N)]
root = sum(range(N)) - N - 1
 
for i in range(N):
    i, l, r = map(int, input().split())
    left[i] = l
    right[i] = r
    root -= (l + r)
 
def preorder(i):
    if i == -1:
        return
    print(' ', i, sep = '', end = '')
    preorder(left[i])
    preorder(right[i])
     
def inorder(i):
    if i == -1:
        return
    inorder(left[i])
    print(' ', i, sep = '', end = '')
    inorder(right[i])
     
def postorder(i):
    if i == -1:
        return
    postorder(left[i])
    postorder(right[i])
    print(' ', i, sep = '', end = '')
     
print('Preorder')
preorder(root)
print()
 
print('Inorder')
inorder(root)
print()
 
print('Postorder')
postorder(root)
print()

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

#define INF_LL (int64_t)1e18
#define INF (int32_t)1e9

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main() {
  int64_t N, Y;
  cin >> N >> Y;

  for (int man = 0; man * 10000 <= Y && man <= N; man++) {
    for (int gosen = 0; man * 10000 + gosen * 5000 <= Y && man + gosen <= N; gosen++) {
      int64_t rest = Y - man * 10000 - gosen * 5000;
      if (rest / 1000 + man + gosen == N) {
        cout << man << " " << gosen << " " << N - man - gosen << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  
  string word, word2, word3, Pal, Pal2, Pal3;
  int L, L3;
  cin >> word;
  L = word.size();
  Pal = word;
  
  reverse(Pal.begin(), Pal.end());
  
  for(int i = 0;i < (L - 1) / 2;i++){
  word2 = word2 + word.at(i);
  }
  Pal2 = word2;
  reverse(Pal2.begin(), Pal2.end());
  
  L3 = (L + 3) / 2;
  for(int i = 0;i < L - L3 + 1 ;i++){
  word3 = word3 + word.at(L3 - 1 + i);
  }
  Pal3 = word3;
  reverse(Pal3.begin(), Pal3.end());
  
  if(word == Pal && word2 == Pal2 && word3 == Pal3){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	int b, sum = 0, max = 0;
	for( int i=0; i<n; i++ ) {
		cin >> a[i];
	}
	sort(a, a+n);
	for( int i=0; i<n; i++ ) {
		sum += a[i];
	}
	max = sum;
	for( int i=0; max%10==0&&i<n; i++ ) {
		max = sum - a[i];
	}
	if( max%10==0 ) {
		max = 0;
	}
	cout << max << endl;
//    int n;
//    int a, b;
//    vector<int> num;
//    int m;
//    cin >> n >> a >> b;;
//    for( int i=0; i<n; i++ ) {
//    	cin >> m;
//    	num.push_back(m);
//	}
//	int cnt = 0;
//	sort(num.begin(), num.end(), [](int a, int b){
//			return a>b;
//		});
//	do{
//		num[0] -= a;
//		int len = num.size();
//		for( int i=1; i<len; i++ ) {
//			num[i] -= b;
//		}
////		for( int i=0; i<n; i++ ) {
////			cout << num[i];
////		}
//		cnt++;
//		sort(num.begin(), num.end(), [](int a, int b){
//			return a>b;
//		});
//		cout << '1' << endl;
//	}while( num[0]>0 );
//	cout << endl << cnt;
    return 0;
}


Measured memory_bytes: 256