akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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

    vector<vector<int>> dp(n+1, vector<int>(n+1, 0));
    int out = 0;

    int index = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (s[i-1] == s[j-1] && dp[i-1][j-1] < (j - i)) {
                dp[i][j] = dp[i-1][j-1] + 1;

                if (dp[i][j] > out) {
                    out = dp[i][j];
                    index = max(i, index);
                }
            } else
                dp[i][j] = 0;
        }
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 98176
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {

    int n;
    cin >> n;
    vector<double> p(n, 0);
    REP(i, n) cin >> p[i];

    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1;
    REP(i, n) {
        REP(j, n) {
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }
    }

    double ans = 0;
    for (int i = n - n/2; i <= n; i++) ans += dp[n][i];
    cout << setprecision(10) << ans << endl;
    
}

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

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

    int len = s.size();

    int i,j,ans = 10000;
    for (i = 0; i <= len - 3; i ++)
    {
        ans = min(ans,abs(753 - ((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0'))));
    }
    cout << ans << endl;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    int ans = 0;
    ans += 1000 * (N / 500);
    N = N % 500;
    ans += 5 * (N / 5);
    cout << ans << endl;
}

Measured memory_bytes: 256
cards = [list(input()) for _ in range(3)]


def solve(cards):
    turn_map = {'a': 0, 'b': 1, 'c': 2}
    if len(cards[0]) == 1:
        return 'a'

    next_player = 'a'
    while True:
        player_cards = cards[turn_map[next_player]]
        if len(player_cards) == 0:
            return next_player
        next_player = player_cards.pop(0)


print(solve(cards).upper())


Measured memory_bytes: 3060
#include<iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = a;
    if(k > a){
        k = k - a;
        k = k - b;
        if(k > 0){
            cout << ans - k;
        }
        else{
            cout << ans;
        }
    }
    else{
        cout << k;
    }
}

Measured memory_bytes: 3616
// ÐÐµ Ñ‚Ð¾Ñ‚ Ð²ÐµÐ»Ð¸Ðº, ÐºÑ‚Ð¾ Ð½Ð¸ÐºÐ¾Ð³Ð´Ð° Ð½Ðµ Ð¿Ð°Ð´Ð°Ð», Ð° Ñ‚Ð¾Ñ‚ Ð²ÐµÐ»Ð¸Ðº â€” ÐºÑ‚Ð¾ Ð¿Ð°Ð´Ð°Ð» Ð¸ Ð²ÑÑ‚Ð°Ð²Ð°Ð»!
// 0 <--> 100
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
                
//#define int long long
#define ll long long 
bool FLAG = 0;
#define debug(x) if (FLAG) {cerr << #x << " = " << x << endl;}
#define debug_vec(x) if (FLAG) {cerr << #x << " = {"; for (auto to x) cout << to << ", "; cout << "}" << endl}
#define F first
#define S second
#define sqr(x) ((x) * (x))
#define make make_pair
#define pb push_back
#define sz(x) (int)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = (int)1e9 + 7, N = (int)1e6+ 222;
const ll INF = (ll)1e18;

int n, L, a[N], sum;

void solve () {
	cin >> n >> L;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= n - 1; ++i) {
		if (a[i] + a[i + 1] >= L) {
			cout << "Possible" << endl;
			for (int j = 1; j <= i - 1; ++j) cout << j << endl;
			for (int j = n - 1; j >= i + 1; --j) cout << j << endl;
			cout << i << endl;                                       
			return;
		}
	}
	cout << "Impossible";

}

signed main () {
	#ifdef Maga
		freopen("input", "r", stdin);
	#endif  
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);                                              
	int t = 1;
	while (t --) {
		solve ();
	}
	return 0;
}




Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e12;

int main() {
  int n;
  cin >> n;
  ll max_diff = -INF, min_diff = INF, max_sum = -INF, min_sum = INF;
  for (int i = 0; i < n; i++) {
    ll a, b, d, s;
    cin >> a >> b;
    d = a - b;
    s = a + b;
    max_diff = max(max_diff, d);
    min_diff = min(min_diff, d);
    max_sum = max(max_sum, s);
    min_sum = min(min_sum, s);
  }
  ll ans = max(max_diff - min_diff, max_sum - min_sum);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
void solve(){
    int a, b;
    cin >> a;
    cin >> b;
    cout << 6 - a - b << endl;

}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

struct mint{
    static const long long MOD = 998244353;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }

    vector<vector<mint>> dp(n, vector<mint>(s + 1, 0));
    dp.at(0).at(0) = 2;
    if(a.at(0) <= s){
        dp.at(0).at(a.at(0)) = 1;
    }
    for(ll i = 1; i < n; ++i){
        for(ll v = 0; v <= s; ++v){
            dp.at(i).at(v) = 2 * dp.at(i - 1).at(v);
            if(v - a.at(i) >= 0){
                dp.at(i).at(v) += dp.at(i - 1).at(v - a.at(i));
            }
        }
    }

    cout << dp.at(n - 1).at(s) << endl;
    return 0;
}


Measured memory_bytes: 73680
#include <iostream>
#include <cassert>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 21
int ans,baseX,baseY;
int w,h;
char tile[MAX][MAX];
void seek(int x,int y);
using namespace std;
int main() {
  while(1){
    cin >> w;
    cin >> h;
    if(w==0&&h==0) return 0;
    rep(i,h){
      rep(j,w){
        cin >> tile[i][j];
        if(tile[i][j] == '@'){
          baseX = i;
          baseY = j;
        }
      }
      tile[i][w] = '#';
    }
    rep(i,w) tile[h][i] = '#';
    ans = 1;
    seek(baseX,baseY);
    cout << ans << endl;
  }
  return 0;
}

void seek(int x,int y){
  if(tile[x+1][y] == '.'){
    tile[x+1][y] = '#';
    ans++;
    seek(x+1,y);
  }
  if(tile[x][y+1] == '.'){
    tile[x][y+1] = '#';
    ans++;
    seek(x,y+1);
  }
  if(tile[x-1][y] == '.'){
    tile[x-1][y] = '#';
    ans++;
    seek(x-1,y);
  }
  if(tile[x][y-1] == '.'){
    tile[x][y-1] = '#';
    ans++;
    seek(x,y-1);
  }
}

Measured memory_bytes: 1188
/*B - ROT N*/

#include <bits/stdc++.h>

using namespace std;

int main(){

	string cad;
	int mov;
	int aux;

	cin >> mov >> cad;

	for (int i = 0; i < cad.size(); ++i)
	{
		if((int)cad[i] + mov > 90)
			aux = 65 + (mov - (90 - (int)cad[i]) - 1);
		else
			aux = (int)cad[i] + mov;
		cout << (char)aux;
	}

	return 0;
}

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

int compare(const void *a,const void *b){
  return *(long *)a - *(long *)b;
}

int main(){
  int n;
  scanf("%d",&n);
  long a[100000];
  int count = 0;
  for(int i=0;i<n;i++){
    scanf("%ld",a+i);
    if(a[i] < 0){
      a[i] = (-1)*a[i];
      count += 1;
    }
  }
  qsort(a,n,sizeof(long),compare);
  long sum=0;
  for(int i=0;i<n;i++){
    sum += a[i];
  }
  if(count % 2 == 1){
    sum -= a[0]*2;
  }
  printf("%ld\n",sum);
  return 0;
}

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000], c[200000];
int b[200000];
signed main() {
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans += abs(a[i]);
	}
	for (int i = 0; i < n - 1; i++) {
		if (a[i] < 0) a[i] *= -1, a[i + 1] *= -1;
	}
	if (a[n - 1] < 0) {
		int res = Inf;
		for (int i = 0; i < n; i++) {
			res = min(abs(a[i]), res);
		}
		ans -= 2 * res;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
bool check(vector<int> &p,vector<vector<int>> &v)
{
  for(int i=0;i<p.size()-1;i++)
    if(v[p[i]][p[i+1]]==0)
      return false;
 /* for(auto i:p)
    cout<<i<<" ";
  cout<<"\n";  */
  return true;
}
int main()
{
  int n,m;
  cin>>n>>m;
  vector<vector<int>> v(n,vector<int>(n,0));
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    v[a-1][b-1]=1;
    v[b-1][a-1]=1;
  }
  vector<int> p(n);
  for(int i=0;i<n;i++)
    p[i]=i;
  int ans=0;
  do
  {
   // if(p[0]!=0) break;
    if(check(p,v))
      ans++;
  }while(next_permutation(p.begin()+1,p.end()));
  
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
numbers = gets.chomp.split(' ').map(&:to_i)
alice_score = 0
bob_score = 0
numbers.sort.reverse.each.with_index(1) do |num, i|
  alice_score += num if i.odd?
  bob_score += num if i.even?
end
puts alice_score - bob_score


Measured memory_bytes: 1788
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    multiset<ll> a;
    REP(_, n) {
        ll tmpa; cin >> tmpa; a.insert(tmpa);
    }
    ll ans = 0;
    while(!a.empty()) {
        ll a1 = *(--a.end());
        a.erase(--a.end());
        ll pow2=1, tmp=1;
        while (a1 >= pow2) {
            pow2 <<= 1; tmp++;
        }
        ll a2 = pow2 - a1;
        if (a.find(a2) != a.end()) {
            a.erase(a.find(a2));
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
///////////////////


int main(){
    int a,b,k; cin >> a >> b >> k;
    int ans, times=0;
    for(int i=100;i>0;i--){
        if(a % i == 0 && b % i == 0){
            ans = i;
            times += 1;
            if(times == k){
                break;
            }
        }
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  char now = S[0];
  ll count = 1;
  for (ll i = 1; i < S.length(); i++) {
    if (now != S[i]) {
      count++;
      now = S[i];
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll n;
    cin >> n;
    map<ll,ll> zyoushi;
    
    for(ll i=0; i<n-1; i++){
        ll a;
        cin >> a;
        zyoushi[a-1]++;
    }
    rep(i,n){
        cout << zyoushi[i] << endl;
    }
}

Measured memory_bytes: 16108
N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)

require 'pp'
def debug obj
  # PP.pp obj, STDERR
end
debug [N,K]
debug A
sum = 0
sumA = A.map{|a| sum += a }
bt_list = []

(0..(N)).to_a.combination(2) do |l,r|
  bt_list.push(((sumA[r] || 0) - sumA[l]).abs)
end

bt_list.sort!.reverse!
debug bt_list

r = 0

max = sumA.last

maxlog = Math.log2(max).to_i
bt_list_size = bt_list.size
maxlog.downto(0) do |i|
  count = 0
  ra = r + (1 << i)
  bt_list.each_with_index do |bt, j|
    if ra == ( ra & bt )
      count += 1
      if count >= K
        r = ra
        break
      end
    end
    if (bt_list_size - j -1) < K - count
      break
    end
  end
end

puts r

Measured memory_bytes: 13560
L=lambda:list(map(int,input().split()));n,m=L();t=sorted([L()for _ in range(n)]+[[float("inf")]]);import heapq as q;h=[];a=j=0
for i in range(t[0][0],m+1):
  while t[j][0]==i:q.heappush(h,-t[j][1]);j+=1
  if h:a-=q.heappop(h)
print(a)

Measured memory_bytes: 31884
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>

using namespace std;

int N;
int a[112345];
int cnt[112345];
int ans;
int main() {
    // insert code here...
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a[i];
        cnt[a[i]]++;
        cnt[a[i]+1]++;
        if(a[i]>0)
            cnt[a[i]-1]++;
    }
    for(int x=0;x<100010;x++){
        if(ans<cnt[x]){
            ans = cnt[x];
        }
    }
    cout << ans  << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
import math


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    ng = 0
    ok = max(A)
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        k = sum([(a-1) // mid for a in A])
        if k <= K:
            ok = mid
        else:
            ng = mid
    return ok


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 31016
# -*- coding: UTF-8 -*-

n = int(input())
l = list(map(int, input().split()))
l.reverse()
f = 0

for i in range(len(l)-1):
    if l[i] >= l[i+1]:
        continue
    else:
        if l[i] >= l[i+1] - 1:
            l[i+1] -= 1
        else:
            f = 1

    if f == 1:
        break

if f == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 15020
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Measured memory_bytes: 38256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) {
        cout << s[i] << t[i]; 
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

ll Max(ll a,ll b,ll c){
	ll max=a;
	if(max<b)max=b;
	if(max<c)max=c;
	return max;
}
class SOLVE{
	vector<vector<ll>> q;
	vector<ll> p;
	public:
	SOLVE(vector<ll> tmp){
		REP(i,3){
			p.push_back(tmp[i]);
		}
	}
	void in(ll t){
		ll i=q.size();
		q.push_back(vector<ll>(3,-INF));
		REP(j,3){
			if((t+2)%3==j){
				if(i==0){
					q[i][j]=p[j];
				}else{
					REP(k,3){
						if(k!=j && q[i][j]<q[i-1][k]+p[j])q[i][j]=q[i-1][k]+p[j];
					}
				}
			}else{
				if(i==0){
					q[i][j]=0;
				}else{
					REP(k,3){
						if(k!=j && q[i][j]<q[i-1][k])q[i][j]=q[i-1][k];
					}
				}
			}
		}
		//cout << "q: "; REP(j,(signed)q[i].size()) cout<<q[i][j]<<" "; cout << endl; //----------cout----------//
	}
	ll out(){
		ll n=q.size();
		return Max(q[n-1][0],q[n-1][1],q[n-1][2]);
	}
};

int main(){
	ll n; cin>>n;
	ll k; cin>>k;
	vector<ll> p(3);
	REP(i,3) cin>>p[i];
	string S; cin>>S;
	vector<ll> t(n);
	REP(i,n){
		if(S[i]=='r')t[i]=0;
		if(S[i]=='s')t[i]=1;
		if(S[i]=='p')t[i]=2;
	}
	vector<SOLVE> s(k,p);
	REP(i,n){
		s[i%k].in(t[i]);
	}
	ll ans=0;
	REP(i,k){
		ans+=s[i].out();
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 14208
N = gets.to_i
P = gets.split(' ').map(&:to_i)
cnt = 0
(1...N-1).each{ |i|
  if P[i-1] < P[i]
    cnt += 1 if P[i] <= P[i+1]
  elsif P[i-1] >= P[i]
    cnt += 1 if P[i] > P[i+1] 
  end
}
puts cnt

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

int main() {
    int n;
    int before = -1;
    int ans = 0;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    for(int i = 0; i < n; i++) cin >> a.at(i);
    for(int i = 0; i < n; i++) cin >> b.at(i);
    for(int i = 0; i < n-1; i++) cin >> c.at(i);
    for(int i = 0; i < n; i++){
        ans += b.at(a.at(i)-1);
        if(before + 1 == a.at(i)) ans += c.at(before - 1);
        before = a.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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 V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<string> C(N);
    vector<int> D(N);
    for(int i = 0; i < N;i++) cin >> C[i] >> D[i];
    int M; cin >> M;
    vector<string> O(M);
    for(auto& in:O) cin >> in;
    
    
    map<string,vector<int>> mp;
    for(int i = 0; i < N;i++){
        mp[C[i]].push_back(D[i]);
    }
    for(auto& p:mp){
        sort(p.second.rbegin(),p.second.rend());
    }
    
    int pred = -1;
    for(int i = 0; i < M;i++){
        vector<int>& v = mp[O[i]];
        while(!v.empty() && pred >= v.back()){
            v.pop_back();
        }
        if(v.empty()) return "No";
        pred = v.back();
        v.pop_back();
    }
    return "Yes";
    // return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}



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

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

    ll H[N];
    for(ll i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    bool Hbool[N];
    for(ll i = 0; i < N; i++)
    {
        Hbool[i] = true;
    }

    ll A[M];
    ll B[M];
    for(ll i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
        if(H[A[i]-1] < H[B[i]-1])Hbool[A[i]-1]=false;
        else if(H[A[i]-1] > H[B[i]-1])Hbool[B[i]-1]=false;
        else 
        {
            Hbool[A[i]-1] = false;
            Hbool[B[i]-1] = false;
        }
    }

    ll count = 0;

    for(ll i = 0; i < N; i++)
    {
        if(Hbool[i] == true)count++;
    }
    cout << count << endl;
    
}

Measured memory_bytes: 6044
from collections import deque

S = deque(input())
Q = int(input())
cnt = 2
for _ in range(Q):
    L = input().split()
    if L[0] == "1":
        cnt += 1
    elif L[0] == "2":
        if L[1] == "1" and (cnt)%2 == 0:
            S.appendleft(str(L[2]))
        elif L[1] == "1" and (cnt)%2 != 0:
            S.append(str(L[2]))
        elif L[1] == "2" and (cnt)%2 == 0:
            S.append(str(L[2]))
        elif L[1] == "2" and (cnt)%2 != 0:
            S.appendleft(str(L[2]))
S ="".join(S)
if cnt%2 != 0:
        print(S[::-1])
else:
        print(S)

            
        
    

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

int main(){
    string A; cin >> A;
    ll N = A.size();
    ll ans = 0;

    map<char, ll> mp;
    rep(i, 0, N){
        mp[A[i]]++;
    }
    ll sub = 0;
    for(auto e: mp){
        sub += e.second * (e.second - 1) / 2;
    }
    ans = 1 + N * ( N - 1) / 2 - sub;
    cout << ans << endl;

}

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



long long int calcLucas(int n,vector<long long int> &LT){
  if(LT[n]!=-1)return LT[n];
  else{
    LT[n] = calcLucas(n-1,LT) + calcLucas(n-2,LT);
    return LT[n];
  }
}

int main(){
  int N;
  scanf("%d",&N);
  vector<long long int> LucasTable(100,-1);
  LucasTable[0]=2;
  LucasTable[1]=1;
  //printf("%ld",calcLucas(N,LucasTable));
  cout << calcLucas(N,LucasTable) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace  std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 2e5 +5 ;
int n , k;

int main () {
    fastIO
    cin>>n>>k;
    ll ans  =0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    int sum=0,M=N;
    while(M>0){
        sum += M%10;
        M/=10;
    }
    if(N % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int N,n[100],A,i,j,t,z,flag;
	flag=1;
	scanf("%d\n",&N);
	for (i=0;i<N;i++){
		scanf("%d",&n[i]);
	}
	t=0;
	while (flag==1){
		flag=0;
	for (i=N-1;i>=1;i--){
			if(n[i-1]>n[i]){
				A=n[i-1];
				n[i-1]=n[i];
				n[i]=A;
				t++;
				flag=1;
			}
		}
	}
	for (i=0;i<N;i++){
		printf("%d",n[i]);
		if (i!=N-1){
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n",t);
	return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
#include <math.h>
 
int main(int argc, const char * argv[])
{
 
    int i, j, temp, data[10];
	
	for (i = 0; i < 10; i++) {
		scanf("%d", &data[i]);
	}
	
	for (i = 0; i < 9; i++) {
		for (j = i + 1; j < 10; j++) {
			if (data[i] < data[j]) {
				temp = data[j];
				data[j] = data[i];
				data[i] = temp;
			}
		}
	}
	
	printf("%d\n%d\n%d\n", data[0], data[1], data[2]);
     
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        String w = sc.next();
        String w2 = w.toLowerCase();
        String t = "",t2="";
        while (true) {
            t = sc.next();
            t2 = t.toLowerCase();
            if (w2.equals(t2)) count++;
            else if (t.equals("END_OF_TEXT")) break;
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26276
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>

using namespace std;
typedef long long ll;

const int MAXN = 100100;
ll X[MAXN];

vector<int> mul(const vector<int>& A, const vector<int>& B) {
	int n = A.size();
	vector<int> ret(n);
	for (int i = 0; i < n; i++) {
		ret[i] = A[B[i]];
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> X[i];
	int M;
	ll K;
	cin >> M >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		A[i] = i;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		--a;
		swap(A[a-1], A[a]);
	}
	vector<int> ans(N);
	for (int i = 0; i < N; i++) {
		ans[i] = i;
	}
	for (int i = 0; i <= 60; i++) {
		if ((K>>i)&1) {
			ans = mul(ans, A);
		}
		A = mul(A, A);
	}
	ll y = X[0];
	for (int i = 0; i < N; i++) {
		cout << y << endl;
		y -= X[ans[i]] - X[ans[i]+1];
	}
	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll long long
#define vi vector <int >
#define vii vectir < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second
 
 
int main(){
	ios::sync_with_stdio(0),cin.tie(0);

    int n, k, s;
    cin >> n >> k >> s;
    int aux;
    if(s == 1)
        aux = 50;
    else{
        if(s == 1000000000){
            aux = s - 1;
        }else{
            aux = s + 1;
        }
    }

    forn(i, k - (k == n)){
        cout << s << " ";
    }
    if(k == n){
        cout << s << endl;
    }else if(k < n){
        rep(i, k, n - 1){
            cout << aux<<" ";
        }
        cout << aux << endl;
    }


   
    return 0;
}

Measured memory_bytes: 1280
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int N=sc.nextInt();
		int[] A=sc.nextIntArray(N);
		int sum=0;
		for (int i = 0; i < A.length; i++) {
			sum^=A[i];
		}
		for (int i = 0; i < A.length; i++) {
			out.println(sum^A[i]);
		}
		out.flush();
 	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 47708
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int min_p = 0;
  int ng = 0;
  for(int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    if((i == 0)||(min_p>=p))  min_p = p;
    else ng++;
  }
  cout << n - ng << endl;
  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & (-x))
#define BIT(a,b) ((ll)(a&(1<<b))==0 ? false : true)

const ll MAXN=2e5+10;

ll a[MAXN];

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

    ll n,t,res=0,k=0;
    cin>>n>>t;

    cin>>a[0];
    k=t;

    for(ll i=1;i<n;i++)
    {
        cin>>a[i];

        if ((a[i]-a[i-1])<=k)
        {
            res+=(a[i]-a[i-1]);
            k=t;
        }
        else
        {
            res+=k;
            k=t;
        }
    }

    res+=k;

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 1920
N,H=gets.split.map &:to_i
a = Array.new(N+1)
b = Array.new(N+1)
a[0]=0
b[0]=0
for i in 1..N
  a[i],b[i]=gets.split.map &:to_i
end
a=a.sort .reverse
b=b.sort.reverse
Sum=0
k=0
loop{
  if b[k]>a[0]
    Sum+=b[k]
    if Sum>=H
      print(k+1)
      exit
    end
  else
    break
  end
k+=1
}
print(k+((H-Sum)/a[0].to_f).ceil)


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

using ll = long long;

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        ans += a-1;
    }
    cout << ans << endl;
    return 0;
}  

Measured memory_bytes: 256
n,m = list(map(int, input().split()))
graph = [set() for _ in range(n)]
for _ in range(m):
    a,b = list(map(int, input().split()))
    graph[a-1].add(b-1)
    graph[b-1].add(a-1)

stack = []
group = [-1] * n
gid = 0
i = 0
for i in range(n):
    if group[i] >= 0:
        continue
    group[i] = gid
    stack.append(i)
    while stack:
        current = stack.pop()
        for neighbor in graph[current]:
            if group[neighbor] == -1:
                group[neighbor] = gid
                stack.append(neighbor)
    gid += 1

print(gid-1)

Measured memory_bytes: 42648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int a, b, c;
    bool A, B;
    int ans = 0;

    for (int pass = 0; pass < 1000; pass++) {
        c = pass % 10, b = (pass / 10) % 10, a = pass / 100;
        A = false, B = false;

        for (int i = 0; i < N; i++) {
            if (!A && S[i] == '0' + a) {
                A = true;
                continue;
            }

            if (A && !B && S[i] == '0' + b) {
                B = true;
                continue;
            }

            if (A && B && S[i] == '0' + c) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define int long long
//#define double long double
#define moder 1000000007
#define P std::pair<int,int>
using namespace std;

int n,a[110];
int selectionsort(){
	int ans=0;
	rep(i,n){
		int minj=i;
		for(int j=i;j<n;j++){
			if(a[j]<a[minj])minj=j;
		}
		swap(a[i],a[minj]);
		if(i!=minj)ans++;
	}
	return ans;
}
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	int ans=selectionsort();
	rep(i,n-1)cout<<a[i]<<" ";
	cout<<a[n-1]<<endl<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int n,m,x,y;
vector<int> ft[N];
int dp[N]={};
int dfs(int x)
{
	int i;
	if(dp[x]>0)
	{
		return dp[x];
	}
	for(i=0;i<ft[x].size();i++)
	{
		dp[x]=max(dp[x],1+dfs(ft[x][i]));
	}
	return dp[x];
}
int main(){
	int i,j,ans=0;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		ft[x-1].push_back(y-1);
	}
	for(i=0;i<n;i++)
	{
		ans=max(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
n = gets.to_i
p = []
n.times{|i|
  x, y = gets.split.map(&:to_f)
  p[i] = [x, y]
}
p << p[0]

sum = 0
n.times{|i|
  sum += p[i][0]*p[i+1][1] - p[i+1][0]*p[i][1]
}
p sum.abs / 2

Measured memory_bytes: 8672
#include<algorithm>
#include<utility>
#include<queue>
#include<string>
using namespace std;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
#define _CRT_SECURE_NO_WARNINGS
int N,Z,W;
int a[2010];
int ans = 0;
int dp[2010][2002][2] = {};
int Score(int now,int p,bool Xturn) {
	if (dp[now][p][Xturn]!=-1) {
		return dp[now][p][Xturn];
	}
	int r;
	if (Xturn) {
		r = 0;
		for (int i = 1; i <= N - now; i++) {
			r = max(r, Score(now + i,now+i-1,false));
		}
		r = max(r, abs(a[N] - a[p]));
	}
	else {
		r = 1000000010;
		for (int i = 1; i <= N - now; i++) {
			r = min(r, Score(now + i, now + i - 1, true));
		}
		r = min(r, abs(a[N] - a[p]));
	}
	return dp[now][p][Xturn]=r;
}
int main() {

	scanf("%d %d %d", &N,&Z,&W);
	for (int i = 1; i <= N;i++) {
		scanf("%d",&a[i]);
		for (int j = 1; j <=N+1 ;j++) {
			dp[j][i][0] = -1;
			dp[j][i][0] = -1;
		}
	}
	ans = abs(W-a[N]);
	for (int i = 1; i <= N-1;i++) {
		ans = max(ans,Score(1+i,i,false));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 31488
def frog():
    N = int(input())
    h = list(map(int, input().split()))

    cost = list()

    cost.append(0)

    for i in range(1, len(h)):
        if i == 1:
            cost.append(abs(h[i]-h[i-1]))

        else:
            cost.append(min(abs(h[i]-h[i-1])+cost[i-1], abs(h[i]-h[i-2])+cost[i-2]))

    print(cost[-1])


if __name__ == "__main__":
    frog()

Measured memory_bytes: 13980
#include <stdio.h>
int main(void)
{
	int h, m, s;
	int temp;

	scanf("%d", &s);

	h = s / 3600;
	temp = s % 3600;

	m = temp / 60;

	s = temp % 60;


	printf("%d:%d:%d\n", h, m,s);
	return(0);
}

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main() {
    string Sp;
    string T;
    string S[50];
    int index = 0;
    bool flag;
    cin >> Sp;
    cin >> T;
    for(int i = 0; i < Sp.size(); i++){
        flag = true;
        S[index] = Sp;
        for(int j = 0; j < i; j++){
            if (S[index][j] == '?')
                S[index][j] = 'a';
        }
        for(int j = 0; j < T.size(); j++) {
            if (Sp[i + j] != T[j] && Sp[i + j] != '?') {
                flag = false;
                break;
            }
        }
        for(int j = i + T.size(); j < Sp.size(); j++){
            if (S[index][j] == '?')
                S[index][j] = 'a';
        }
        if(flag){
            for(int j = 0; j < T.size(); j++){
                S[index][i + j] = T[j];
            }
            index++;
        }
    }
    if(index == 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    Sp = S[0];
    for(int i = 0; i < index; i++)
        if(S[i] < Sp)
            Sp = S[i];
    cout << Sp << endl;
    return 0;
}

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

int main(void){
	int H, W;
	while(cin >> H >> W, H+W){
		int D = H*H + W*W;
		priority_queue<tuple<int,int,int>> q;
		for(int h = 1; h < 150; ++h){
			for(int w = h+1; w < 150; ++w){
				q.emplace(-(h*h+w*w), -h, -w);
			}
		}
		while(1){
			tuple<int,int,int> t = q.top();
			if(-get<0>(t) == D && -get<1>(t) > H) break;
			if((-get<0>(t)) > D) break;
			q.pop();
		}
		printf("%d %d\n", -get<1>(q.top()), -get<2>(q.top()));
	}
	return 0;
}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, d, x;
  cin >> n >> d >> x;
  ll count = 0;
  vi a(n);
  rep(i,n){
    cin >> a[i];
    for (ll j = 0; a[i] * j+1 <= d;j++){
      count++;
    }
  }
  print(count + x);
}


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

using namespace std;

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

struct Node {
	int a, b, ma, mb;
	
	Node() {}
	Node(int a, int b, int ma, int mb) : a(a), b(b), ma(ma), mb(mb) {}
};

int n;
Node node[100];
bool istop[100];

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

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

int dfs(int pos) {
	Node &now = node[pos];
	
	int a = now.a, b = now.b, ma = now.ma, mb = now.mb;
	
	ma = ma ? dfs(ma - 1) : 1;
	mb = mb ? dfs(mb - 1) : 1;
	
	int l = lcm(a * ma, b * mb);
	return l / a + l / b;
}

int main() {
	while (cin >> n, n) {
		fill(istop, istop + n, false);
		
		REP(i, n) {
			int a, b, ma, mb;
			scanf("%d %d %d %d", &a, &b, &ma, &mb);
			node[i] = Node(a, b, ma, mb);
			
			if (ma != 0) istop[ma - 1] = true;
			if (mb != 0) istop[mb - 1] = true;
		}
		
		int st = 0;
		while (istop[st]) st++;
		cout << dfs(st) << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
/**
 * Created by karayuu on 2019/02/24
 */
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var btc = 0.0
    var money = 0

    for (i in 1..n) {
        val (k, s) = readLine()!!.split(" ")
        if (s == "JPY") {
            money += k.toInt()
        } else {
            btc += k.toDouble()
        }
    }

    println(btc * 380000 + money)
}


Measured memory_bytes: 37664
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;

vector<long long> sieve(const long long& n)
{
    vector<long long> v(n + 1);
    vector<bool> c(n + 1, 1);
    vector<long long> ret;
    for (long long i = 2; i <= n; ++i)
    {
        if (c[i])
        {
            for (long long j = 2 * i; j <= n; j += i)
            {
                c[j] = 0;
            }
            ret.push_back(i);
        }
    }
    return ret;
}


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    vector<ll> p = sieve(1e6);
    map<ll, ll> m;
    for (int i = 0; i < p.size(); ++i)
    {
        while (n % p[i] == 0)
        {
            m[p[i]]++;
            n /= p[i];
        }
    }
    if (n != 1)
    {
        m[n]++;
    }
    ll ret = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr)
    {
        ll cur = itr->second;
        for (int i = 1; i < 100; ++i)
        {
            ll v = ((1 + i) * i) / 2;
            if (v > cur)
            {
                ret += (i - 1ll);
                break;
            }
        }
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 12224
#include<iostream>
#include<algorithm>
#include <tuple>
using namespace std;
int main()
{
    vector< tuple<int, int, char,long long int , string> > v;
    int n;
    cin>>n;
    while(n--)
    {
        int a,b;
        long long int c;
        string s;
        char x;
        cin>>a>>b>>x>>c>>s;
        auto tup1=make_tuple(a,b,x,c,s);
        v.push_back(tup1);
    }
    sort(v.begin(),v.end());
    for(auto z:v)
    {
        int a,b;
        long long int c;
        string s;
        char x;
        tie(a,b,x,c,s)=z;
        cout<<a<<" "<<b<<" "<<x<<" "<<c<<" "<<s<<endl;
    }
}


Measured memory_bytes: 12256
fun main(args: Array<String>) {
    var i = 0
    while(true)
    {
        i = i + 1
        val list = readLine()!!.split(" ").map(String::toInt)
        if (list[0]==0)
        {
            return
        }
        println("Case %d: %d".format(i,list[0]))
    }
}


Measured memory_bytes: 66480