akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll P = 1000000007;
  ll n;std::cin >> n;
  vector<ll> a(n);
  ll zero_count = 0;
  for(int i=0;i<n;i++) {
    if(a[i]==0) zero_count++;
    std::cin >> a[i];
  }
  if(zero_count==1) {
    std::cout << 3 << '\n';
    return 0;
  }
  ll ans = 1;
  vvl dp = vv(2*n+2, 3, 0, ll);
  for(int i=1;i<=n;i++){
    int idx = 0, c = 0;
    dp[i][0] = dp[i-1][0], dp[i][1] = dp[i-1][1], dp[i][2] = dp[i-1][2];
    if(a[i-1]==dp[i][0]) c++,idx=0;
    if(a[i-1]==dp[i][1]) c++,idx=1;
    if(a[i-1]==dp[i][2]) c++,idx=2;
    ans = (ans*c)%P;
    dp[i][idx]++;
    //std::cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2]  << '\n';
  }
  std::cout << ans<< '\n';
  return 0;
}


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

using namespace std;
using ll = long long;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll dx[] = { 1,0 };
ll dy[] = { 0,1 };

int main() {

    ll H, W;
	cin >> H >> W;

    vector<vector<char>>s(100, vector<char>(100));

	rep(i, H) {
		rep(j, W) {
			cin >> s[i][j];
		}
	}

    vector<vector<ll>> dp(H, vector<ll>(W, mod));

    dp[0][0] = 0;
    if (s[0][0] == '#') dp[0][0]++;

    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            for (ll k = 0; k < 2; k++) {
                ll nx = j + dx[k];
                ll ny = i + dy[k];
                if (ny >= H || nx >= W) continue;
                if (s[i][j] == '.' && s[ny][nx] == '#') dp[ny][nx] = min(dp[ny][nx], dp[i][j] + 1);
                else dp[ny][nx] = min(dp[ny][nx], dp[i][j]);
            }
        }
    }

    cout << dp[H - 1][W - 1] << endl;


	return 0;
}

Measured memory_bytes: 3724
Times =[int(input())for i in range(5)]
def realtime(n):
    return (-(-n//10))*10

def amari(n):
    if n%10 == 0:
        return 10
    else:
        return n%10

Realtimes = list(map(realtime,Times))
amaris = list(map(amari,Times))
finalist = amaris.index(min(amaris))

ans = sum(Realtimes) + Times[finalist] - Realtimes[finalist]
print(ans)

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

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }

  ll ans=0;
  vector<ll> count(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A.at(i)>A.at(j)){
        count.at(i)++;
        if(i<j){
          ans++;
        }
      }
    }
  }
  ans%=MOD;
  ans*=K;
  ans%=MOD;

  for(int i=0;i<N;i++){
    ans+=(K*(K-1)/2%MOD)*(ll)count.at(i);
    ans%=MOD;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;
using ll=long long;


int main() {
  int k,x;cin >> k >> x;
  int sum = 500*k;
  cout << (sum>=x?"Yes":"No");
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, k, mod=1e9+7, fac[200009], dp[100009], fac2[200009];
vector<int> v[100009];
int solve(int node, int p)
{
    int &ans=dp[node];
    if(ans!=-1)
        return ans;
    ans=1;
    int sz=v[node].size();
    if(node==1)
    {
        sz++;
        ans=fac[max(0,k-sz+1)];
        for(auto i : v[node])
            ans=(1LL*ans*solve(i,node))%mod;
        return ans;
    }
    sz--;
    if(sz==0)
    return 1;
    ans=fac2[max(0,k-2-sz+1)];
    for(auto i : v[node])
        if(i!=p)
            ans=(1LL*ans*solve(i,node))%mod;
    return ans;
}
int main()
{
    IO
    cin>>n>>k;
    for(int i=1; i<n; i++)
    {
        int x, y ;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    fac[k]=k;
    for(int i=k-1; i>=1; i--)
        fac[i]=(1LL*fac[i+1]*i)%mod;
    if(k>2)
    {
        fac2[k-2]=k-2;
        for(int i=k-3; i>=1; i--)
            fac2[i]=(1LL*fac2[i+1]*i)%mod;
    }
    memset(dp,-1,sizeof dp);
    cout<< solve(1,0);
}


Measured memory_bytes: 12160
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);  
    #endif

    int n,m,k;
    cin >> n >> m >> k;
    vector<string> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < (1 << m); j++) {
            int cnt = 0;
            for (int o = 0; o < n; o++) {
                for (int oo = 0; oo < m; oo++) {
                    if (((i >> o) & 1) == 0 && ((j >> oo) & 1) == 0 && v[o][oo] == '#')
                        cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans;

    #ifndef ONLINE_JUDGE   
    std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	int sum = 0;
	cin >> s;
	if (s[0] < '9')
	{
		int i = 1;
		int sumt = s[0] - '0';
		while (i < s.size() && s[i] == '9')
		{
			++i;
			sumt += 9;
		}
		if (i == s.size())
		{
			cout << sumt;
			return 0;
		}
		sum += (s[0] - '0' - 1);
		for (int i = 1; i < s.size(); ++i)
			sum += 9;
		cout << sum;
		return 0;
	}
	else
	{
		sum += 9;
		int i = 1;
		while (i < s.size() && s[i] == '9')
		{
			sum += 9;
			++i;
		}
		if (i == s.size())
		{
			cout << sum;
		}
		else
		{
			--sum;
			for (i; i < s.size(); ++i)
				sum += 9;
			cout << sum;
		}
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] trees = new int[N];
    for(int i = 0; i < N; i++){
      trees[i] = sc.nextInt();
    }
    Arrays.sort(trees);
    int min = 1000000000;
    for(int i = 0; i < N - K + 1; i++){
      int d = trees[i+K-1] - trees[i];
      min = d > min ? min : d;
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 49836
a, b = gets.split.map &:to_i
if a <= 0 && b >= 0
  puts :Zero
elsif (a < 0 && b < 0)
  if (b-a).odd?
    puts :Positive
  else
    puts :Negative
  end
elsif (a > 0 && b > 0)
  puts :Positive
else
  puts :Negative
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>

typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	int bc = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i]=='B') {
			int mv = (s.size()-bc)-(i+1);
			ans += mv;
			bc++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    vector<ll> x(n), y(n);
    int i,j;
    for (i = 0; i < n; i++) {
        scanf("%lld%lld", &x[i], &y[i]);
    }
    double sum = 0;
    for (i = 0; i < n; i++) {
        for (j = i+1; j < n; j++) {
            sum += sqrt(((double)x[j] - x[i])*((double)x[j] - x[i]) + ((double)y[j] - y[i])*((double)y[j] - y[i]));
        }
    }
    sum /= n;
    sum *= 2;
    printf("%.10lf\n", sum);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, j, k;
	ll ans = 0, a;
	cin >> num;
	vector<string> s(num);
	for (i = 0; i < num; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	for (a = 1, i = 0; i < num - 1; i++) {
		if (s[i] == s[i + 1])
			a++;
		else {
			ans += (a * (a - 1)) >> 1;
			a = 1;
		}
	}
	ans += (a * (a - 1)) >> 1;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 7296
n,m,k=gets.chomp.split(" ").map(&:to_i);

(n+1).times do |x|
  (m+1).times do |y|
    if (n-x)*(m-y) == n*m-k-x*y
      print 'Yes'
      exit
    end
  end
end

print 'No'

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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, x, t; cin >> n >> x >> t;
    int ans = t;
    while(n > x)
    {
        n -= x;
        ans += t;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#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 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
ll n;
ll a[200000+5];
ll till[200000+5];
ll bk[200000+5];

int main(){
	scanf("%lld", &n);
	FOR(i,1,n){
		ll cur;
		scanf("%lld", &cur);
		a[i] = cur;
		if(till[i-1] < cur) till[i] = cur;
		else till[i] = till[i-1];
		//cout << till[i] << ' ';
	}
	for(int i=n;i>=1;i--){
		if(a[i] > bk[i+1]) bk[i] = a[i];
		else bk[i] = bk[i+1];
		//cout << bk[i] << ' ';
	}
	FOR(i,1,n){
		cout << max(till[i-1], bk[i+1]) << endl;
	}
    return 0;
}


Measured memory_bytes: 6272
n = int(input())
ans = [0 for i in range(10001)]
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      v = x**2+y**2+z**2+x*y+y*z+z*x
      if v<=10000:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])

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

int main(void){
    int AB;
    int BC;
    int CA;
    cin >> AB >> BC >> CA;

    vector<int> time;
    time.emplace_back(AB + BC);
    time.emplace_back(AB + CA);
    time.emplace_back(BC + CA);

    cout << *min_element(time.begin(), time.end()) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N, A[100002] = { 0 };
	int tmp;
	int max = 0;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> tmp;
		A[tmp]++;
	}

	for (int i = 0; i < 100000; i++)
	{
		int tmp = A[i] + A[i + 1] + A[i + 2];
		if (tmp > max)
			max = tmp;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 1272
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;


int main(){
    int n, m , a, b;
    cin >> n >> m;
    int amount[n+1];
    rep( i , n) amount[i] = 1;
    bool red[n+1];
    red[1] = true;
    rep(i , m){
        cin >> a >> b;
        amount[a]--;
        amount[b]++;
        if ( red[a]) red[b] = true;
        if ( amount[a] == 0) red[a] = false;
        
        
    }
    int ans = 0;
    rep( i , n){
        if ( red[i] ) ans++;
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 4024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String a = s.next();
		String b = s.next();
		String answer = "D";

		if (a.equals("H")) {
			if (b.equals("H")) {
				answer = "H";
			} else if (a.equals("D")) {

			}
		} else if (a.equals("D")) {
			if (b.equals("H")) {

			} else if (a.equals("D")) {
				answer = "H";
			}
		}
		System.out.println(answer);

	}

}

Measured memory_bytes: 21844
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

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

	static void solve() {
		int n = in.nextInt();
		if(n >= 30) System.out.println("Yes");
		else System.out.println("No");
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}





Measured memory_bytes: 32720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------

bool b[10000000];
int cnfa[1000000];

int main(){
  int N,M;
  cin >> N >> M;
  int ac = 0, fal = 0;
  
  rep(i,M){
    int p;string s;
    cin >> p >> s;
    if(b[p] == false && s == "WA") cnfa[p]++;
    else if(b[p] == false && s == "AC"){
      ac++;
      b[p]=true;
      fal += cnfa[p];
    } 
  }
  cout << ac << " "<< fal << endl; 
  
  
  return 0;
}




Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main (){
    int n ;
    cin >> n ;
    vector<int> a (n) ;
    vector<int> ans ;
    int tot = 0 ;
    int g = 0 ;
    rep(i, n) cin >> a[i] ;
    rep(i, n) tot += a[i] ;
    rep(i, n){
        if(i % 2 == 1){
            g += 2 * a[i] ;
        }
    }
    int x = tot - g ;
    int t = 0 ;
    while(t != n){
        ans.push_back(x) ;
        x = 2 * a[t] - x ;
        t++ ;
    }
    rep(i, ans.size()){
        cout << ans[i] << " " ;
    }
    cout << endl ;
}

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v)
{
    for (auto& e : v) {
        is >> e;
    }
    return is;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

constexpr int MAX = 2500000;
int m[MAX + 1];
ll nsum[MAX + 1];
ll msum[MAX + 1];

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

    ll M, N, m0, md, n0, nd;
    cin >> M >> N >> m0 >> md >> n0 >> nd;
    // vector<int> m(M);
    // vector<ll> nsum(N);
    m[0] = m0;
    nsum[0] = n0;
    for (ll i = 1; i < M; i++) {
        m[i] = (m[i - 1] * 58 + md) % (N + 1);
    }
    for (ll i = 1; i < N; i++) {
        nsum[i] = (nsum[i - 1] * 58 + nd) % (M + 1);
    }
    // const ll SM = accumulate(m.begin(), m.end(), 0LL);
    const ll SM = accumulate(m, m + M, 0LL);
    sort(m, m + M, greater<ll>());
    sort(nsum, nsum + N);
    // sort(m.begin(), m.end(), greater<ll>());
    // sort(nsum.begin(), nsum.end());
    // show(m);
    // show(n);
    // vector<ll> msum(M + 1, 0LL);
    for (ll i = 1; i <= M; i++) {
        msum[i] = msum[i - 1] + m[i - 1];
    }
    for (ll i = 1; i < N; i++) {
        nsum[i] += nsum[i - 1];
    }
    nsum[N] = 0;
    // nsum.push_back(0LL);
    // sort(nsum.begin(), nsum.end());
    sort(nsum, nsum + N + 1);

    // show(msum);
    // show(nsum);
    ll mini = INF<ll>;
    for (ll i = 0; i <= N; i++) {
        ll sum = SM + nsum[i];
        mini = min(mini, sum + M * i);
        const ll value = N - i;
        const ll l = lower_bound(m, m + M, value, greater<int>{}) - m;
        // const ll l = lower_bound(m.begin(), m.end(), value, greater<int>{}) - m.begin();
        sum += -msum[l] + l * (N - i);
        mini = min(mini, sum);
    }
    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 52024
#include <iostream>
#include <algorithm>
#define USER_SIZE 100000
#define NIL -1

using namespace std;

int group[USER_SIZE];

int update(int num){
    if(num == group[num]){ return num; }
    else{ return group[num] = update(group[num]); }
}

int main(){
    int n, m, s, t, q;

    cin >> n >> m;
    for(int i = 0; i < n; i++){
        group[i] = i;
    }
    for(int i = 0; i < m; i++){
        cin >> s >> t;
        int tmp1 = update(s);
        int tmp2 = update(t);
        group[max(tmp1, tmp2)] = min(tmp1, tmp2);
    }

    cin >> q;
    while(q--){
        cin >> s >> t;
        if(update(s) == update(t)){ cout << "yes" << endl; }
        else{ cout << "no" << endl; }
    }

    return 0;
}


Measured memory_bytes: 3484
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=sc.nextLong();
		
		
		long dc=d*c/gcd((int)d,(int)c);
		
		long x1=b/c;
		long x2=b/d;
		long x3=b/dc;
		
		long ans1=x1+x2-x3;
		//System.out.println(ans1);
		
		long t1=(a-1)/c;
		long t2=(a-1)/d;
		long t3=(a-1)/dc;
		
		long ans2=t1+t2-t3;
		//System.out.println(ans2);
		
		System.out.println((b-a+1)-(ans1-ans2));
		
		
	}
	public static int gcd(int num1,int num2) {
        if(num2==0) return num1;
        else return gcd(num2,num1%num2);
    }
}
	


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "delete" :
            list.delete( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public String getAllElements() {
    StringBuilder buf = new StringBuilder(size*4);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf.toString();
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


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

int main (void){
    string s;
    int n = 0;
    cin >> s; 
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '+'){
            n += 1;
        }else{
            n -= 1;
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> p;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    p.push(tmp);
  }
  for(int i=0; i<m; i++){
    int tmp=p.top();
    p.pop();
    p.push(tmp/2);
  }
  long long int ans = 0;
  while(!p.empty()){
    ans += p.top();
    p.pop();
  }
  cout << ans;
  return 0;
}

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

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

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy"){
        cout << "Rainy" << endl;
    } else if (S == "Rainy") {
        cout << "Sunny" << endl;
    } else {

    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i,k;
	ll l=0,r=0,ans=0;
	std::cin >> n >> k; --k;
	for(i=0; i<=n; ++i){
		l += i;
		r += (n-i);
		if(i>=k){
			add_mod(ans,(r-l+1)%MOD);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3632
a = input().split(' ')
result = []
result.append(int(a[0]))
result.append(int(a[1]))
result.append(int(a[2]))
result.append(int(a[3]))
subresult = []
subresult.append(result[0]*result[2])
subresult.append(result[0]*result[3])
subresult.append(result[1]*result[2])
subresult.append(result[1]*result[3])
print(max(subresult))



Measured memory_bytes: 9128
from collections import Counter
from math import factorial
N=input()
A=map(int, raw_input().split())
b=[]

def product(iterable):
    prod = 1
    for n in iterable:
        prod *= n
    return prod

def npr(n, r):
    return product(range(n - r + 1, n + 1))

def ncr(n, r):
    if r > n // 2:
        r = n - r
    return npr(n, r) // factorial(r)

A_sum=0
for i in A:
	A_sum+=i
	b.append(A_sum)

c=Counter(b)

ans=0
for i,j in c.items():
	if i==0:
		ans+=ncr(j+1,2)
	elif j>=2:
		ans+=ncr(j,2)
		
print ans


Measured memory_bytes: 44756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n,a[55],b[55];
bool g[55][55][55],val[55][55];
ll ret;
int main() {
	scanf("%d",&n);
	rep(i,0,n) scanf("%d",a+i);
	rep(i,0,n) scanf("%d",b+i);
	rep(j,0,51) g[0][j][j]=1;
	rep(k,1,51) rep(i,0,51) rep(j,0,51) g[k][i][j]=g[k-1][i%k][j]|g[k-1][i][j];
	rep(i,0,n) val[i][a[i]]=1;
	bool valid=1;
	rep(i,0,n) if (!g[50][a[i]][b[i]]) valid=0;
	if (!valid) {
		puts("-1");
		return 0;
	}
	per(k,1,51) {
		bool valid=1;
		rep(i,0,n) {
			bool ff=0;
			rep(j,0,51) ff|=val[i][j]&&g[k-1][j][b[i]];
			if (ff==0) valid=0;
		}
		if (!valid) {
			ret+=1ll<<k;
			rep(i,0,n) rep(j,0,51) val[i][j%k]|=val[i][j];
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <cmath>
#include <unordered_set>
#include <sstream>
#define Endl endl
#define inf 0x3f3f3f3f
 
using namespace std;
typedef long long  ll;
 
const double pi=acos(-1);
ll GCD(ll a,ll b){return b==0?a:GCD(b,a%b);}




int main(){
    
 
    
    ll x;cin>>x;
    int cnt=0;
    ll ans=100;
    while (1) {
        cnt++;
        ll tt=ans*0.01;
        ans+=tt;
        if(ans>=x) break;;
    }
    cout<<cnt<<endl;
    
    
    
    return 0;
    
}


Measured memory_bytes: 3188
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let a: Vec<usize> = parse!(it, n);
    let mut b: Vec<usize> = parse!(it, n);
    let mut count = 0;
    loop {
        let mut flag = false;
        for i in 0..n {
            let s = match i {
                0 => b[n - 1] + b[1],
                i if i == n - 1 => b[0] + b[n - 2],
                i => b[i - 1] + b[i + 1],
            };
            if b[i] <= s || a[i] == b[i] {
                continue;
            }

            let next = if a[i] >= s { a[i] } else { b[i] % s };
            if (b[i] - next) % s != 0 {
                break;
            }
            flag = true;
            count += (b[i] - next) / s;
            b[i] = next;
        }
        if !flag {
            break;
        }
    }
    if (0..n).all(|i| a[i] == b[i]) {
        println!("{}", count);
    } else {
        println!("{}", -1);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

using namespace std;

typedef long long ll;

struct s_tree
{
	vector<ll> st, lazy;

	s_tree(int n) : st(4*n, 0), lazy(4*n, 0) {}

	inline void push(int c, int b, int e, int m)
	{
		if (lazy[c] != 0)
		{
			st[c<<1] += (m-b)*lazy[c];
			st[c<<1|1] += (e-m)*lazy[c];
			lazy[c<<1] += lazy[c];
			lazy[c<<1|1] += lazy[c];
			lazy[c] = 0;
		}
	}

	ll query(int c, int b, int e, int l, int h)
	{
		if (b >= l && e-1 <= h)
			return st[c];
		int m = (b+e)>>1;
		push(c, b, e, m);
		ll s = 0;
		if (l < m)
			s += query(c<<1, b, m, l, h);
		if (m <= h)
			s += query(c<<1|1, m, e, l, h);
		return s;
	}

	void update(int c, int b, int e, int l, int h, ll v)
	{
		if (b >= l && e-1 <= h)
		{
			st[c] += v * (e-b);
			lazy[c] += v;
			return;
		}
		int m = (b+e)>>1;
		push(c, b, e, m);
		if (l < m)
			update(c<<1, b, m, l, h, v);
		if (m <= h)
			update(c<<1|1, m, e, l, h, v);
		st[c] = st[c<<1]+st[c<<1|1];
	}
};

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

	int n, q;
	cin >> n >> q;

	ll t, a, b, x;
	s_tree st(n+2);
	while (q--)
	{
		cin >> t >> a >> b;
		if (t)
		{
			cout << st.query(1, 1, n+2, a, b) << "\n";
			continue;
		}
		cin >> x;
		st.update(1, 1, n+2, a, b, x);
	}

	return 0;
}



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

using namespace std;

typedef long long ll;
const int MAX_N = 10;
const int MAX_S = 1001;
 
ll dp[MAX_N][MAX_S];
 
void init()
{
    for (int i = 0; i <= MAX_N*MAX_N; i++) {
	dp[1][i] = 1;
    }
    for (int i = 2; i < MAX_N; i++) {
	for (int j = 1; j < MAX_S; j++) {
	    if(j >= i) dp[i][j] += dp[i][j-i];
	    if(j >= (i-1)) dp[i][j] += dp[i-1][j-(i-1)];
	    if(j >= 101) dp[i][j] -= dp[i-1][j-101];
	}
    }
}
 
int main()
{
    int n, s;
    init();
    while (cin >> n >> s, (n + s)) {
	cout << dp[n][s] << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  int count = 0;
  for(int i = 0; i < N.length(); i++){
  	if(N.at(i) == '2'){
    	count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  char a, b; cin >> a >> b;
  string A, B;
  for (int i = 0; i < b - '0'; i++) A += a;
  for (int i = 0; i < a - '0'; i++) B += b;

  cout << (A < B ? A : B) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int h,w;
    cin >> h >> w;
    vector<string> g(h);
    rep(i,h){
        cin >> g[i];
    }
    Graf ans(h,vector<int>(w));
    rep(i,h){
        rep(j,w){
            
            int count=0;
            if(i>0){
                if(j>0){
                    if(g[i-1][j-1]=='#'){
                        count++;
                    }
                }
                if(g[i-1][j]=='#'){
                    count++;
                }
                if(j<w-1){
                    if(g[i-1][j+1]=='#'){
                        count++;
                    }
                }
            }
            if(j>0){
                if(g[i][j-1]=='#'){
                    count++;
                }
            }
            if(j<w-1){
                if(g[i][j+1]=='#'){
                    count++;
                }
            }
            if(i<h-1){
                if(j>0){
                    if(g[i+1][j-1]=='#'){
                        count++;
                    }
                }
                if(g[i+1][j]=='#'){
                    count++;
                }
                if(j<w-1){
                    if(g[i+1][j+1]=='#'){
                        count++;
                    }
                }
            }
            ans[i][j]=count;
            
            
        }
    }

    rep(i,h){
        rep(j,w){
            if(g[i][j]!='#')
                cout << ans[i][j];
            else
            {
                cout << '#';
            }
            
        }cout << endl;
    }
}

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

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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int temp = 0;
    temp = x;
    x = y;
    y = temp;
    temp = x;
    x = z;
    z = temp;
    cout << x << " " << y << " " << z << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

ans = 0
for i in a:
    count = 0
    j = i
    while j >= 0:
        if j % 2 == 0:
            j = int(j/2)
            count += 1
        else:
            break
    ans += count

print(ans)

Measured memory_bytes: 4148
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt(); //じゃんけんをする回数
		int k = stdIn.nextInt(); //k回目までのじゃんけんは好きな手を出せる
		int r = stdIn.nextInt(); //グーで勝った時の得点
		int s = stdIn.nextInt(); //パーで勝った時の得点
		int p = stdIn.nextInt(); //チョキで勝った時の得点

		String t = stdIn.next(); //筐体の出す手の文字列
		int ans = 0;
		String[] hand = new String[n];

		for(int i = 0; i < k; i++) {
			if(t.charAt(i)== 'r') {
				ans += p;
				hand[i] = "p";
			}else if(t.charAt(i)=='s') {
				ans += r;
				hand[i] = "r";
			}else {
				ans += s;
				hand[i] = "s";
			}

		}

		for(int i = k; i < n; i++) {

			if(t.charAt(i)== 'r') {
				if(!hand[i-k].equals("p")) {
					ans += p;
					hand[i] = "p";
				}else if(i < t.length()-k) {
					if(t.charAt(i+k) == 's') {
						hand[i] = "s";
					}else {
						hand[i] = "r";
					}
				}
			}
			if(t.charAt(i)== 's') {
				if(!hand[i-k].equals("r")) {
					ans += r;
					hand[i] = "r";
				}else if(i < t.length()-k){
					if(t.charAt(i+k)== 'p') {
						hand[i] = "p";
					}else {
						hand[i] ="s";
					}
				}
			}
			if(t.charAt(i)== 'p') {
				if(!hand[i-k].equals("s")) {
					ans += s;
					hand[i] = "s";
				}else if(i < t.length()-k){
					if(t.charAt(i+k)== 'r') {
						hand[i] = "r";
					}else {
						hand[i] = "p";
					}
				}
			}
		}



			System.out.println(ans);

	}
}

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

int main()
{
  int w, a, b;
  std::cin >> w >> a >> b;
  if (w < b - a)
  {
    std::cout << b - a - w << std::endl;
  }
  else if (b - a <= w && a <= b)
  {
    std::cout << 0 << std::endl;
  }
  else if (b < a && a - b < w)
  {
    std::cout << 0 << std::endl;
  }
  else
  {
    std::cout << a - b - w << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		int z = stdIn.nextInt();
		String ans;
		if( x < y && y < z) {
			ans = "Yes";
		} else {
			ans = "No";
		}
		stdIn.close();
		System.out.println(ans);

	}

}



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

int main() {
	char str;
	int n[3]={},ans=0,x;
	while(cin>>str){
		if(str=='J'&&n[1]==0&&n[2]==0)n[0]++;
		else if(str=='O'&&n[1]<n[0]&&n[2]==0)n[1]++;
		else if(str=='I'&&n[2]<min(n[0],n[1])){
			n[2]++;
			if(n[2]==min(n[0],n[1]))ans=max(ans,min(n[0],n[1]));
		}
		else {
			for(int i=0;i<3;i++)n[i]=0;
			if(str=='J')n[0]=1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1144
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt(); 
        int i=0;
        for (i=1;i<n+1;i++){
            if(i%3==0){
                System.out.print(" "+ i);
            }
            else if(Integer.toString(i).contains("3")){
                System.out.print(" "+ i);
            }
        }
        System.out.printf("\n");
    }
}


Measured memory_bytes: 28980
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,a,b;
    cin>>n;
    vector<pair<int,int>> A;
    rep(i,n) cin>>a,A.push_back(make_pair(a,1));
    rep(i,n) cin>>b,A.push_back(make_pair(b,2));
    sort(A.begin(),A.end());
    ll ans=1,mod=1e9+7,x=0,y=0;
    rep(i,2*n){
        if(x==0) y=A[i].second,x++;
        else{
            if(y==A[i].second) x++;
            else ans=ans*x%mod,x--;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 2420
import sys
mod = 1000000007
def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())
def input(): return sys.stdin.readline()
def main():
    n = int(input())
    v = get_array()
    v.sort()
    s = (v[0] + v[1])/2
    for i in range(2, n):   s = (s + v[i])/2
    print(s)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3192
n = int(input())
h = [int(x) for x in input().split()]

INF = 10**10
dp = [INF]*n

dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]))

print(dp[n-1])



Measured memory_bytes: 20524
n,k=map(int,input().split())
a=[int(s) for s in input().split()]
b=[0]*k
c=0
v=[0]*n
v[0]=a[0]
for i in range(n-1):
    v[i+1]=v[i]+a[i+1]
mx=v[k-1]
for i in range(k,n):
    g=v[i]-v[i-k]
    mx=max(mx,g)  
    
print((mx+k)/2)


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

int main()
{
    int arr1[52],arr2[52];
    int n,c=0;

    cin>>n;

    for(int i=0; i<n; i++)
    {
        cin>>arr1[i];
    }
    for(int j=1; j<=n; j++)
    {
        arr2[j-1]=j;
    }
    for(int k=0; k<n; k++)
    {
        if(arr1[k]!=arr2[k])
        {
            c++;
        }
    }
    if(c==0 || c==2)
        cout<<"YES"<<endl;
    else
        cout<<"NO\n"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<map>
#define lli long long int
using namespace std;

int main() {
	// your code goes here
	lli a,b;
	string s;
	string t;
	string u;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==s){
		cout<<--a<<" "<<b;
	}
	else{
		cout<<a<<" "<<--b;
	}
	return 0;
}

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

using namespace std;

static int N;
static bool cards[52];

inline static int suit_to_i(char s) {
    return s == 'S' ? 0
                    : s == 'H' ? 1
                               : s == 'C' ? 2
                                          : 3;
}

inline static char i_to_suit(int i) {
    int d = i / 13;
    return d == 0 ? 'S'
                  : d == 1 ? 'H'
                           : d == 2 ? 'C'
                                    : 'D';
}

int main(void) {

    cin >> N;

    for (int i = 0; i < N; ++i) {
        char s;
        int r;
        cin >> s >> r;
        cards[13 * suit_to_i(s) + (r - 1)] = true;
    }

    for (int i = 0; i < 52; ++i) {
        if (! cards[i]) {
            printf("%c %d\n", i_to_suit(i), i % 13 + 1);
        }
    }

    return 0;
}

Measured memory_bytes: 1144
//usr/bin/picoc $0 - $@;exit
#include <stdio.h>
int main(){
	int a,b,c,t=0,i;
	scanf("%d%d%d",&a,&b,&c);
	for(i=0;i<60;i++){
		if(c<=t+a)break;
		t+=a+b;
		for(;c<=t;)c+=60;
	}
	printf("%d\n",i==60?-1:c);
	return 0;
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string s;
	cin >> s;

	int win = 0;
	for (char c : s)if (c == 'o')win++;
	win += 15 - s.size();

	cout << (win < 8 ? "NO" : "YES") << endl;



	return 0;
}

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

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n,a[100007],tot;
int main(){
  cin >> n;
  for(int i = 1; i<=n; i++) cin >> a[i];
  for(int i = 0; i<=n; i++) tot+=abs(a[i]-a[i+1]);
  for(int i = 1; i<=n; i++)
    printf("%d\n", tot+abs(a[i-1]-a[i+1])-abs(a[i]-a[i+1])-abs(a[i]-a[i-1]));
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n, A;        

const int N = 50;
         
ll dp[N + 1][N*N + 1];

int a[Sz];
              
int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n >> A;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
                   
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int k = i; k >= 1; k--) {
      for (int s = a[i]; s <= N * N; s++) { 
        dp[k][s] += dp[k - 1][s - a[i]];
      }
    }
  }      
  ll ans = 0;                   
  for (int i = 1; i <= n; i++)
    ans = (ans + dp[i][A * i]);
  cout << ans;    


  return 0;
}






// Coded by Z..



Measured memory_bytes: 1280