akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 1, x; i < n; i++) {
        cin >> x;
        --x;
        ++a[x];
    }
    for (auto &i : a) cout << i << '\n';
}


Measured memory_bytes: 4020
#include <iostream>
using namespace std;
int main(void){
    long long n,a,b,c,d,p,l,r;
    cin>>n>>a>>b>>c>>d;
    p=b-a;
    n--;
    if(p<-n*d||p>n*d){
        cout<<"NO"<<endl;
        return 0;
    }
    l=0;
    r=n+1;
    while(l+1<r){
        long long m=(l+r)/2;
        if(p>=m*c-(n-m)*d){
            l=m;
        }else{
            r=m;
        }
    }
    if(p<=l*d-(n-l)*c){
        cout<<"YES"<<endl;
        return 0;
    }
    cout<<"NO"<<endl;
    return 0;
}


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

const int MAXN = 1010, MOD = 1000000007;
int H, W, memo[MAXN][MAXN];
char G[MAXN][MAXN];

int solve(int r, int c) {
    if(r >= H || c >= W || G[r][c] == '#')
        return 0;
    else if(r == H-1 && c == W-1)
        return 1;
    else if(memo[r][c] != -1)
        return memo[r][c];
    else return memo[r][c] = ((solve(r+1,c) % MOD) + (solve(r,c+1) % MOD)) % MOD;
}

int main() {
    cin >> H >> W;

    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
            cin >> G[i][j];

    memset(memo, -1, sizeof memo);
    cout << solve(0,0) << "\n";
}

Measured memory_bytes: 5248
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

int main() {

	int N, K;
	int count = 0;

	cin >> N >> K;

	while (N != 0) {
		N = N / K;
		count++;
	}

	cout << count << endl;

}

Measured memory_bytes: 256
import sys
import numpy as np
read = sys.stdin.read


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if x == y:
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, *xy = map(int, read().split())
xy = np.array(xy, np.int64).reshape(N, 2)

town = np.arange(N)
arg_x = np.argsort(xy[:, 0])
arg_y = np.argsort(xy[:, 1])

edges_x = xy[arg_x[1:], 0] - xy[arg_x[:-1], 0]
town_x = zip(town[arg_x[1:]], town[arg_x[:-1]])
edges_y = xy[arg_y[1:], 1] - xy[arg_y[:-1], 1]
town_y = zip(town[arg_y[1:]], town[arg_y[:-1]])

edges = list(zip(edges_x, town_x)) + list(zip(edges_y, town_y))
edges.sort()

tree = UnionFind(N)
answer = 0

for d, (t1, t2) in edges:
    if tree.isSameGroup(t1, t2):
        continue

    tree.Unite(t1, t2)
    answer += d

print(answer)

Measured memory_bytes: 70416
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int n;
    cin>>n;
    map<string,int> mp;

    int m=0;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
        m=max(m,mp[s]);
    }

    for(auto s:mp){
        if(s.S==m){
            cout<<s.F<<endl;
        }
    }


}

Measured memory_bytes: 23808
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;

  for (i64 i = 1; i <= 9; ++i) {
    for (i64 j = 1; j <= 9; ++j) {
      if (i * j == N) goto SUCCEEDED;
    }
  }

  std::cout << "No" << std::endl;
  return 0;

SUCCEEDED:
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

prise = [300000, 200000, 100000]


ans = 0
if X == 1 and Y == 1:
        ans += 400000

if X <= 3:
        ans += prise[X-1]
if Y <= 3:
        ans += prise[Y-1]

print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
    string o;
    string e;
    string ans;

    cin >> o;
    cin >> e;

    for (int i = 0; i < o.size(); i++) {
        ans.push_back(o[i]);
        if (e[i] != '\0') {
            ans.push_back(e[i]);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int N; cin >> N;
	int h[100100];
	for (int i = 0; i < N; ++i)cin >> h[i];
	int ans = 0;
	int cnt = 0;
	for (int i = 0; i < N - 1;i++) {
		if (h[i] >= h[i + 1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

struct Card
{
	char suit;
	char value;
};

void bubble(Card A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j > i; j--)
		{
			if (A[j].value < A[j - 1].value)
			{
				swap(A[j], A[j - 1]);
			}

		}
	}
}

void selection(Card A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		int tmp = i;
		for (int j = i + 1; j < N; j++)
		{
			if (A[j].value < A[tmp].value)
			{
				tmp = j;
			}
		}
		swap(A[i], A[tmp]);
	}
}

void Print(Card A[], int N)
{
	for (int i = 0; i < N-1; i++)
	{
		cout << A[i].suit << A[i].value << " ";

	}
	cout << A[N-1].suit << A[N-1].value << endl;
}

bool isstable(Card A[], Card C[], int N)
{
	for (int i = 0; i < N; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			int flag = 1;
			if (A[j].value == A[i].value)
			{
				for (int m = 0; m < N; m++)
				{
					if (C[m].value == A[i].value)
					{
						if (C[m].suit != A[i].suit)
							return false;
						else
						{
							C[m] = A[j];
							flag = 0;
							break;
						}
					}
				}
			}
			if (flag == 0)
			{
				break;
			}
		}
	}
	return true;
}


int main()
{
	Card A[100],B[100],C[100],D[100];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i].suit >> A[i].value;
	}
	for (int i = 0; i < N; i++)
	{
		B[i] = A[i];
		C[i] = A[i];
		D[i] = A[i];
	}
	bubble(A, N);
	Print(A, N);
	if(isstable(A, C, N))
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}
	selection(B, N);
	Print(B, N);
	if (isstable(B, D, N))
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979
#define EPS 1e-8
#define mod 1000000007
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
	 
const ll INF=(ll)2e18;
		
		
const int N=2e5+5;
	
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}	

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s1,s2;
	cin>>s1>>s2;
	ll t;
	cin>>t;
	
	ll ca[100050]={0};
	ll cb[100050]={0};
	
	ll Ca[100050]={0};
	ll Cb[100050]={0};
	
	ll n=max(s1.length(),s2.length());
	
	ll i;
	for(i=0;i<s1.length();i++)
	{
		ca[i+1]=ca[i];
		cb[i+1]=cb[i];
		
		if(s1[i]=='A')
			ca[i+1]++;
		else
			cb[i+1]++;
	}
	for(;i<n;i++)
	{
		ca[i+1]=ca[i];
		cb[i+1]=cb[i];
	}
	for(ll i=0;i<s2.length();i++)
	{
		Ca[i+1]=Ca[i];
		Cb[i+1]=Cb[i];
		
		if(s2[i]=='A')
			Ca[i+1]++;
		else
			Cb[i+1]++;
	}
	for(;i<n;i++)
	{
		Ca[i+1]=Ca[i];
		Cb[i+1]=Cb[i];
	}
	
	for(ll i=0;i<t;i++)
	{
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		
		ll cnta= ca[b]-ca[a-1];
		ll cntb= cb[b]-cb[a-1];
		
		ll c1=cnta + 2*cntb;
		
		ll Cnta= Ca[d]-Ca[c-1];
		ll Cntb= Cb[d]-Cb[c-1];
		ll c2=Cnta + 2*Cntb;
		//cout<<cnta<<" "<<cntb<<" "<<Cnta<<" "<<Cntb<<endl;
		
		while(c1<c2)
		{
			c1*=4;
		}
		if((c1-c2)%3==0)
			cout<<"YES\n";
		else
			cout<<"NO\n";
		
		
	}
}


Measured memory_bytes: 4048
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in);
    sc.nextLine()
    val line = sc.nextLine().split(" ").map(_.toInt);
    println(calc(line, 0));
  }

  def calc(line:Array[Int], count:Int) : String = {
    if (line.count(_.toInt%2==0) == line.size) {
      calc(line.map(_.toInt/2), count+1);
    } else {
      count.toString
    }
  }
}

Measured memory_bytes: 25896
#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 pair<ll, ll> pll;
const ll MOD = 1e9 + 7;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	ll cur = 1;
	vl rem(13);
	rem[0] = 1;
	for(auto c: s){
		vl trem(13);
		if(c == '?'){
			for(int i = 0; i < 13; i ++){
				for(int j = 0; j < 10; j ++){
					(trem[(i + j * cur) % 13] += rem[i]) %= MOD;
				}
			}
		}
		else{
			for(int i = 0; i < 13; i ++){
				trem[(i + (c - '0') * cur) % 13] = rem[i];
			}
		}
		rem = trem;
		(cur *= 10) %= 13;
	}
	cout << rem[5];
	return 0;
}

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

int main()
{
    int x,t;
    cin>>x>>t;
    int ans;
    if(x>=t)
    {
        ans=x-t;
        cout << ans << endl;
    }
    else
    {
        ans=0;
        cout << '0' << endl;
    }

    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define taskname "test1"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int A, B;   cin >> A >> B;
    cout << A - B + 1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

int solve()
{
    ll n = 0;
    cin >> n;
    ll a[n];
    ll count0[n+1] = { 0 };
    ll count1[n+1] = { 0 };
    rep(i,n)
    {
        cin>>a[i];
        count0[a[i]]++;
    }
    ll sum =0;
    rep_a(i,1,n+1)
    {
        count1[i] = (count0[i])*(count0[i]-1)/2;
        sum += count1[i];
    }
    rep(i,n)
    {
        ll x =(ll)sum-(ll)count1[a[i]]+((count0[a[i]]-1)*(count0[a[i]]-2)/2);
        cout<<x<<endl;
    }
    return 0;
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif */
    solve();
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
    #endif */

    return 0;
} 

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define per1(i,n) for (int i = n; i >= 1; --i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
// if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W)
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

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

    int N,K; cin >> N >> K;
    vector<PL> D(N);
    vector<ll> X(N), Y(N);
    rep(i, N) {
        int x,y; cin >> x >> y;
        D[i] = {x,y};
        X[i] = x;
        Y[i] = y;
    }

    sort(all(X));
    sort(all(Y));

    ll ans = (X.back() - X.front()) * (Y.back() - Y.front());

    rep(xi, N) {
        reps(xj, xi + 1, N) {
            rep(yi, N) {
                reps(yj, yi + 1, N) {
                    int num = 0;
                    rep(i, N) {
                        if(X[xi] <= D[i].first && X[xj] >= D[i].first && Y[yi] <= D[i].second && Y[yj] >= D[i].second) {
                            ++num;
                        }
                    }
                    if(num >= K) {
                        chmin(ans, (X[xj] - X[xi]) * (Y[yj] - Y[yi]));
                    }
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define rep(i,j) for(int i = 0; i < (j); i++)
int main(){
	int n;
	cin >> n;
	string change[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};	
	while(n--){
		string str;
		cin >> str;
		int len = str.size();
		string ans = "";
		rep(i,len){
			if(str[i] == '0')continue;
			int sub = i;
			while(str[i] == str[++sub]);
			ans += change[str[sub-1]-48][(sub-i-1)%change[str[sub-1]-48].size()];
			i = sub;
		}
		cout << ans << endl;
	}	
	return 0;
}

Measured memory_bytes: 1216
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    A,B = ints_raw()
    return max(A+B,A-B,A*B)
    
print(main())


Measured memory_bytes: 38384
N, K = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
    if psum+a[i] < K :
        psum += a[i]
    else :
        ans = min(ans, i)
print(ans)

'''
notes:
1-->we include elems that are less than k  
2-->if some x is necessary all elems grtr than x are also necessary 
Base for some x to be necessary:: 
     atleast one of the sums in range [sm-x,sm) must be possible 
     excluding x  
now at any instance after traversing x elements 
we make sure that we have max posible sm <k 
now 
if x+sm <k 
    we cannot include this anyway 
otherwise
    we can make a set with {sm,x} now x is important 
BOOYAH (:
'''


Measured memory_bytes: 3572
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int INF = Integer.MAX_VALUE/10;

        while(true){
            int n = sc.nextInt(), m =sc.nextInt();
            if(n==0 && m==0) break;

            int[][] aruki = new int[n][n];
            int[][] fune = new int[n][n];
            for(int i=0; i<n; i++){
                Arrays.fill(aruki[i], INF);
                Arrays.fill(fune[i], INF);
                aruki[i][i] = 0; fune[i][i] = 0;
            }
            for(int i=0; i<m; i++){
                int x = sc.nextInt()-1, y = sc.nextInt()-1, t = sc.nextInt();
                char s = sc.next().charAt(0);
                if(s=='L'){
                    aruki[x][y] = t; aruki[y][x] = t;
                }else{
                    fune[x][y] = t; fune[y][x] = t;
                }
            }

            for(int k=0; k<n; k++)
                for(int i=0; i<n; i++)
                    for(int j=0; j<n; j++){
                        aruki[i][j] = Math.min(aruki[i][j], aruki[i][k]+aruki[k][j]);
                        fune[i][j] = Math.min(fune[i][j], fune[i][k]+fune[k][j]);
                    }
            
            int r = sc.nextInt();
            int[] z = new int[r];
            for(int i=0; i<r; i++) z[i] = sc.nextInt()-1;

            int[][] dp = new int[r][n];
            for(int i=0; i<r; i++) Arrays.fill(dp[i], INF);
            dp[0][z[0]] = 0;
            for(int i=1; i<r; i++){
                for(int j=0; j<n; j++){
                    dp[i][j] = Math.min(dp[i][j], dp[i-1][j] + aruki[z[i-1]][z[i]]);
                    for(int k=0; k<n; k++)
                        dp[i][k] = Math.min(dp[i][k], dp[i-1][j] + aruki[z[i-1]][j] + 
                                            fune[j][k] + aruki[k][z[i]]);
                }
            }

            int min = INF;
            for(int i=0; i<n; i++) min = Math.min(min, dp[r-1][i]);
            System.out.println(min);
        }
    }

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

Measured memory_bytes: 62972
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    string a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
        reverse(a[i].begin(), a[i].end());
    }
    int crt = 0;
    while (1) {
        if (a[crt].empty()) {
            cout << char('A' + crt) << endl;
            return 0;
        }
        int k = a[crt].back();
        a[crt].pop_back();
        crt = k - 'a';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";

int main()
{


    fast;

    lli n,m;
    cin>>n>>m;
    if(n<=m)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";


    return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> T LCM(T a, T b) {
    if (a > b) swap(a, b);
    T r = a%b, c = a, d = b;
    while (r != 0) {a = b; b = r; r = a%b; }
    return c/b*d;
}

bool possible (vector<long long> A) {
    vector<int> cnt(A.size(), 0);
    for (int i = 0; i < A.size(); i++) {
        while (A[i]%2==0) {
            cnt[i]++;
            A[i] /= 2;
        }
    }
    int a = *min_element(cnt.begin(), cnt.end());
    int b = *max_element(cnt.begin(), cnt.end());
    return a==b;
}

int main() {
    int N; long long M;
    cin >> N >> M;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] /= 2;
    }
    if (!possible(A)) { cout << 0 << endl; return 0; }
    
    long long K = 1;
    for (int i = 0; i < N; i++) {
        K = LCM(K, A[i]);
        if (M < K) { cout << 0 << endl; return 0; }
    }
    long long L = K*2;
    long long ans = (M-K)/L+1;
    cout << ans << endl;
    return 0;
}
    

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 2e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define sp              <<" "<<

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }

int main()
{
    fast
       
       ll n;
       cin>>n; 
       
       ll a[n+1];
       forn(i,1,n+1)
       cin>>a[i];
       
       ll dp[n+1][2];  // 0-> not negative 1->negative
       forn(i,0,n+1)
       forn(j,0,2)
       dp[i][j]=-inf;
       
       dp[2][0]=a[1]+a[2];
       dp[2][1]=-(a[1]+a[2]);
       forn(i,3,n+1)
       {
         dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][0]+a[i]);
         dp[i][1]=max(dp[i-1][1]-a[i]+2*a[i-1],dp[i-1][0]-a[i]-2*a[i-1]);
         //cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
       }

       cout<<max(dp[n][0],dp[n][1]);

    return 0;
} 

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

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

  ll T = 0, X = 0, Y = 0;
  for (ll i = 0; i < N; i++)
  {
    ll t, x, y;
    cin >> t >> x >> y;
    if ((t - T) % 2 != (abs(x - X) + abs(y - Y)) % 2)
      FINALANS("No");
    if (t - T < abs(x - X) + abs(y - Y))
      FINALANS("No");
    T = t, X = x, Y = y;
  }
  FINALANS("Yes");
}

Measured memory_bytes: 256
v[5],d[4],o[3];C(x,q,y){q=o[q]-43;x+=q?q-2?0:-y:y;return-~q?x:x*y;}P(){printf(C(C(C(*d,0,d[1]),1,d[2]),2,d[3])-10?C(C(*d,0,d[1]),1,C(d[2],2,d[3]))-10?"":"(%d%c%d)%c(%d%c%d)\n":"((%d%c%d)%c%d)%c%d\n",*d,*o,d[1],o[1],d[2],o[2],d[3])&&main(1);}O(i,j){for(j=3;j--;i?O(i-1):P())o[i]="+-*"[j];}D(i,j){for(j=4;j--;)!d[j]?d[j]=v[i],i<4?D(i+1):O(2),d[j]=0:0;}main(i){for(;scanf("%d",v+i)*v[i];bzero(d,16))++i>4?D(i=1),puts("0"):0;exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,roop=0,ans[100];
    while(cin>>n>>m&&n!=0&&m!=0){
        int p[n],sum=0,h=n/m;
        for(int i=0;i<n;i++){
            cin>>p[i];
            sum+=p[i];
        }
        sort(p,p+n);
        for(int i=1;i<=h;i++){
            sum-=p[n-m*i];
        }
        ans[roop]=sum;
        roop++;
    }
    for(int i=0;i<roop;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3088
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	int count = 0;
	for (int i = a; i <= b; i++)
	{
		if (c % i == 0)
		{
			count++;
		}
	}
	std::cout << count << '\n';
}

Measured memory_bytes: 3108
#include <stdio.h>

int main(void) {
	int handed[30]={0};
	int one;
	int i;
	for(i=0;i<28;i++) {
		scanf("%d",&one);
		handed[one-1]=1;
	}
	for(i=0;i<30;i++) {
		if(!handed[i])printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N, M; cin >> N >> M;
    vector<ll> a(N+1);
    for(int i=1; i<=N; i++) cin >> a[i];

    map<ll, ll> mp;
    vector<ll> cum(N+1, 0);
    for(int i=1; i<=N; i++) { cum[i] = cum[i-1]+a[i]; mp[cum[i]%M]++; };


    ll ans = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if(itr->first == 0) ans += (itr->second*(itr->second-1)/2 + itr->second);
        else ans += itr->second*(itr->second-1)/2;
    }

    cout << ans << endl;


}

Measured memory_bytes: 5760
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll f[n];
    for(ll i = 0; i < n; i++)
        cin>>f[i];
    vector<vector<ll> >dp(n+1,vector<ll>(k+1));
    for(ll i = 0; i <= f[0]; i++)
        dp[1][i] = 1;
    for(ll i = 0; i <= n; i++)
        dp[i][0] = 1;
    for(ll i = 2; i <= n; i++)
    {
        for(ll j = 1; j <= k; j++)
        {
            dp[i][j] = dp[i][j]%mod + dp[i-1][j]%mod + dp[i][j-1]%mod;
            dp[i][j] %= mod;
            if(j - f[i-1] - 1 >= 0)
                dp[i][j] = mod + dp[i][j]%mod - dp[i-1][j-f[i-1]-1]%mod;
            dp[i][j] %= mod;
        }
    }
    cout<<dp[n][k]%mod;
    return 0;
}


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

using namespace std;

int encode(int u, int v){
    if(u>v) swap(u, v);
    return u * 1000 + v;
}
pair<int, int> decode(int node){
    return {node / 1000, node % 1000};
}
vector<int> adj[1000006];
int indeg[1000006];
int n;
int topo(){
    queue<int> q;
    for(int i=0; i<1000006; i++){
        if(!indeg[i])
            q.push(i);
    }
    int cnt = 0;
    int lev = 0;
    while(!q.empty()){
        lev++;
        int sz = q.size();
        for(int i=0; i<sz; i++){
            cnt++;
            int u = q.front();
            q.pop();
            for(int v : adj[u])
                if(!--indeg[v])
                    q.push(v);
        }
    }
    
    return (cnt == 1000006 ? lev : -1);
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif

    scanf("%d", &n);
    for(int u=0; u<n; u++){
        int prv = -1;
        for(int j=0; j<n-1; j++){
            int v;
            scanf("%d", &v);
            --v;
            if(prv != -1){
                adj[encode(u, prv)].push_back(encode(u, v));
                indeg[encode(u, v)]++;
            }
            prv = v;
        }
    }
    printf("%d\n", topo());
    return 0;
}


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

#define MOD 1000000007
 
int main(){
    ll n,k;
    cin>>n>>k;
    ll res=0;
    for(int i=k;i<=n+1;i++){
        res=(res+(n-i+1)*i+1)%MOD;
        //cout<<i<<":"<<res<<endl;
    }
    cout<<res<<endl;
    return 0;
}

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

int main()
{
	while (1) {
		string a;
		cin >> a;
		if (a == "0")break;
		string b, c;
		cin >> b >> c;
		a += b + c;
		if (a[4] != '+' && (a[0] == a[4] && a[4] == a[8] || a[1] == a[4] && a[4] == a[7] || a[2] == a[4] && a[4] == a[6] || a[3] == a[4] && a[4] == a[5]))cout << a[4] << endl;
		else 	if (a[0] != '+' && (a[0] == a[1] && a[1] == a[2] || a[0] == a[3] && a[3] == a[6]))cout << a[0] << endl;
		else 	if (a[8] != '+' && (a[6] == a[7] && a[7] == a[8] || a[2] == a[5] && a[5] == a[8]))cout << a[8] << endl;
		else cout << "NA" << endl;
	}
}

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

wa=0
ac=0

#初期値が0の辞書
from collections import defaultdict
acwa = defaultdict(lambda: [0,0]) 

for _ in range(m):
    p,s=map(str,input().split())

    if s=="AC":
        if acwa[p][0]==0:
            ac+=1
            wa+=acwa[p][1]
            acwa[p][0]=1
    else:
        acwa[p][1]+=1

print(ac,wa)




Measured memory_bytes: 67544
/*
	Name: Harshit Jain
	Institution: IIIT Vadodara
*/
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <list>
#include <stack>
#include <cstring>
#include <map>
#include <queue>
#include <ctime>
#include <iomanip>
#include <set>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <climits>

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ull unsigned long long
#define rep(i,a,b) for(ll i = a; i < b; ++i)
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeofa((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define p(a) cout << a << "\n";
#define p1(a) cout << a << " ";

#define PI 3.141592653589793
#define MOD (ll)(1e9 + 7)
#define m(a) ((a)%MOD)

using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
//=======================

void solve()
{
	string s;
	cin >> s;
	s[3] = '8';
	p(s)
}

//=======================
int main()
{
	bool testing = false;
	IOS
	if(testing)
	{
		freopen("test.txt","rt",stdin);
		int start = clock();
		solve();
		int end = clock();
		cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";
	}
	else
	{
		solve();
	}
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e18 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

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

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n, p, ans = 1;
map<int, int>mp;
signed main() {
	scanf("%lld %lld", &n, &p);
	mp = factring(p);
	for (P p : mp) {
		ans *= modpow(p.first, p.second / n);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int h[100010];
int dp[100010];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	rep(i, n) {
		cin >> h[i];
	}
	rep(i, 100010) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		chmin(dp[i], dp[i-1]+abs(h[i] - h[i - 1]));
		if (i > 1)chmin(dp[i], dp[i-2]+abs(h[i] - h[i - 2]));
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

typedef pair< int, int > pii;

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

int main() {
	int N;
	cin >> N;
	
	map< pii, int > lattice;
	
	for_(i,0,N) {
		int x, y, w;
		cin >> x >> y >> w;
		lattice[pii(x,y)] = w;
	}
	
	int ans = 0;
	
	map< pii, int >::iterator it = lattice.begin(), eit = lattice.end();
	
	for (; it != eit; ++it) {
		pii p = (*it).first;
		
		for_(di,0,2) {
			int val = (*it).second;
			
			for_(dj,0,3) {
				pii fp(p.first + dx[di][dj], p.second + dy[di][dj]);
				if (lattice.count(fp)) val += lattice[fp];
			}
			
			ans = max(ans, val);
		}
	}
	
	cout << ans << " / 1" << endl;
}

Measured memory_bytes: 7448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
using namespace std;

void solve() {
	int k, x;
	cin >> k >> x;
	const char* ans[] = {"No", "Yes"};
	cout << ans[500 * k >= x] << endl;
}

int main() {
	solve();
	return 0;
}


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

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

Measured memory_bytes: 256
class SegmentTree:
    seg_len = 1
    node = []
    def __init__(self, n):
        while self.seg_len < n:
            self.seg_len <<= 1
        self.node = [ 0 for _ in range(self.seg_len*2) ]

    def add(self, idx, v):
        idx += self.seg_len
        self.node[idx] += v
        while True:
            idx >>= 1
            if idx == 0:
                break
            self.node[idx] = self.node[idx*2] + self.node[idx*2+1]

    def sum(self, l, r):
        l += self.seg_len
        r += self.seg_len
        ret = 0
        while l < r:
            if l & 1 == 1:
                ret += self.node[l]
                l += 1
            if r & 1 == 1:
                ret += self.node[r-1]
                r -= 1
            l >>= 1; r >>= 1;
        return ret


n, k = map(int, input().split())
p = [ int(x) for x in input().split() ]

seg_tree = SegmentTree(n)
for i in range(n):
    seg_tree.add(i, (1+p[i])/2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, seg_tree.sum(i, i+k))

print(ans)


Measured memory_bytes: 111624
K, N = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)

ans = 1000000000
for i in range(0, N):
    if i == 0:
        a = A[-1] - A[0]
        b = (K-A[i+1]) + A[0]
    if i == N-1:
        a = (K-A[i]) + A[i-1]
        b = A[-1]-A[0]
    else:
        a = (K - A[i]) + A[i-1]
        b = A[i] + (K - A[i+1])
    ans = min(ans, min(a, b))

print(ans)

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

int s[101], t[101];
int main(){
	int a, b, n, ans = 0;
	scanf("%d%d%d", &a, &b, &n);
	for(int i = 0;i < n;i++)scanf("%d%d", &s[i], &t[i]);
	for(int i = 0;i < n;i++){
		if(b <= s[i] || t[i] <= a);
		else ans = 1;
	}
	printf("%d\n", ans);
	return 0;
}


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

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

    ll a, b;
    cin >> a >> b;
    a--;
    int tmp = a % 4;
    if(tmp == 1)a = 1;
    else if(tmp == 2)a++;
    else if(tmp == 3)a = 0;
    else if(tmp == -1)a = 0;

    tmp = b % 4;
    if(tmp == 1)b = 1;
    else if(tmp == 2)b++;
    else if(tmp == 3)b = 0;

    ll ans = a ^ b;//aとbの排他的論理和
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int N,X;
    cin >> N >>X;
    int m=1001;
    int sum=0;
    rep(i,N){
        int a;
        cin >> a;
        m=min(m,a);
        sum+=a;
    }
    X=X-sum;
    int ans = N;
    ans+=X/m;
    cout << ans << endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			int[] aArray = new int[n];

			int allXor = 0;
			for(int i = 0 ; i < n ; i++ ) {
				aArray[i] = sc.nextInt();
				allXor = allXor ^ aArray[i];
			}
			
			for(int i = 0 ; i < n ; i++ ) {
				
				System.out.println(aArray[i] ^ allXor);
			}
			
		}
	}

}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

const int INF = 1001001001;
typedef pair<int, int> P;
const int dh[] = {-1, 0, 1, 0};
const int dw[] = {0, -1, 0, 1};

void solve() {
    int H, W;
    cin >> H >> W;
    char table[H][W];
    REP(i, H) {
        REP(j, W) {
            cin >> table[i][j];
        }
    }
  
    int ans = 0;
    REP(i, H) {
        REP(j, W) {
            if (table[i][j] == '#') continue;
            vector<vector<int>> dist(H, vector<int>(W, INF));
            
            queue<P> q;
            auto update = [&](int a, int b, int x) {
                if (dist[a][b] != INF) return;
                dist[a][b] = x;
                q.push(P(a, b));
            };
            update(i, j, 0);
            while (!q.empty()) {
                auto item = q.front(); q.pop();
                int a = item.first;
                int b = item.second;
                REP(k, 4) {
                    int ci = a + dh[k];
                    int cj = b + dw[k];
                    if (ci < 0 || cj < 0 || ci >= H || cj >= W) continue;
                    if (table[ci][cj] == '#') continue;
                    update(ci, cj, dist[a][b]+1);
                }

            }
            int tmp = 0;
            REP(a, H) {
                REP(b, W) {
                    if (dist[a][b] == INF) continue;
                    tmp = max(tmp, dist[a][b]);
                }
            }
            ans = max(ans, tmp);
        }
    }
    print(ans);
}

signed main() {
    solve();
}


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

namespace test
{


    class Program
    {
        static void Main(string[] args)
        {
            List<int> trainList = new List<int>();
            List<int> outTrainList = new List<int>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                int a = int.Parse(input);
                if (a == 0)
                {
                    int outTrain = trainList[trainList.Count - 1];
                    trainList.RemoveAt(trainList.Count - 1);
                    outTrainList.Add(outTrain);
                }
                else
                {
                    trainList.Add(a);
                }

            }

            foreach (int t in outTrainList)
            {
                Console.WriteLine(t);
            }


        }


    }
}

Measured memory_bytes: 5664
n, k = map(int, input().split())
MOD = 10**9+7
red_num = n - k
blue_num = k

def prepare(n, MOD):
    """
    nCr mod MOD
    n!/r!/(n-r)! → facts(n)*invs(r)*invs(n-r)
    :param n:
    :param MOD:
    :return:
    """
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    _invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs

for i in range(1, k+1):
    if red_num+1 < i:
        print(0)
        continue
    facts1, inves1 = prepare(red_num+1, MOD)
    facts2, inves2 = prepare(k-1, MOD)
    a = facts1[red_num+1]*inves1[i]*inves1[red_num+1-i]%MOD
    b = facts2[k-1]*inves2[i-1]*inves2[k-i]%MOD

    print(a*b%MOD)




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

int main() {
    int N; cin >> N;
    int P[10]; rep(i, N) cin >> P[i];
    sort(P, P + N);
    int ans = 0;
    rep(i, N) ans += P[i] / 2;
    rep(i, N - 1) ans += P[i] / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640