akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], signed n) {
    string result = "{";
    for (int i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  	int n; cin >> n;
  	cout << n*n;
}

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

int main()
{
	int n, m, a[50], b[50], c[50], d[50];
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%d%d", a + i, b + i);
	for (int i = 0; i < m; i++) scanf("%d%d", c + i, d + i);
	for (int i = 0; i < n; i++)
	{
		int min_j{};
		for (int j = 1; j < m; j++)
		{
			if (std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]) < std::abs(a[i] - c[min_j]) + std::abs(b[i] - d[min_j]))
				min_j = j;
		}
		printf("%d\n", min_j + 1);
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int a[100][100],b[100],c[100],i,j,n,m; /*b???m??????c???i??? */
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
    
  }

  for(j=0;j<m;j++){
    scanf("%d",&b[j]);
  }
  

  for(i=0;i<n;i++){
    c[i]=0;
    for(j=0;j<m;j++){
      c[i]+=a[i][j]*b[j];
    }
  }







    

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

  return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int R, C, N;
int x[212345], y[212345];

int main() {
	cin >> R >> C >> N;
	REP(i, 2 * N) scanf("%d %d", x + i, y + i);
	
	vector<pii> u, r, d, l;
	set<int> ss;
	
	REP(i, 2 * N) {
		if (y[i] == 0) u.push_back(pii(x[i], i / 2));
		else if (x[i] == R) r.push_back(pii(y[i], i / 2));
		else if (y[i] == C) d.push_back(pii(x[i], i / 2));
		else if (x[i] == 0) l.push_back(pii(y[i], i / 2));
		else ss.insert(i / 2);
	}
	
	sort(ALL(u));
	sort(ALL(r));
	sort(ALL(d), greater<pii>());
	sort(ALL(l), greater<pii>());
	
	vector<int> v;
	REP(i, u.size()) v.push_back(u[i].se);
	REP(i, r.size()) v.push_back(r[i].se);
	REP(i, d.size()) v.push_back(d[i].se);
	REP(i, l.size()) v.push_back(l[i].se);
	
	stack<int> st;
	REP(i, v.size()) {
		if (ss.find(v[i]) != ss.end()) continue;
		
		if (st.size() > 0 && st.top() == v[i]) st.pop();
		else st.push(v[i]);
	}
	
	puts(st.empty() ? "YES" : "NO");
	
	return 0;
}


Measured memory_bytes: 8948
N, *A = map(int, open(0).read().split())

A = [0] + A + [0]

acc = [0] * (N + 2)
for i in range(N + 1):
    acc[i + 1] = acc[i] + abs(A[i + 1] - A[i])

for i in range(N):
    left = acc[i] - acc[0]
    right = acc[N + 1] - acc[i + 2]
    print(left + abs(A[i + 2] - A[i]) + right)



Measured memory_bytes: 20468
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main() {
    int n; cin >> n;
    printf("%.10lf\n", ((n+1)/2)/(n*1.0));

    return 0;
}

// EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

int main()
{
    fastread();

    ll n,m;

    cin>>n>>m;

    ll ara[n+1];


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




    sort(ara, ara+n);

    vector<pair<ll,ll>>v;

    for(ll i=0;i<m;i++)
    {
        ll v1,v2;

        cin>>v1>>v2;

        v.eb(v2,v1);

    }


    sort(v.rbegin(),v.rend());


    vector<ll>p;
    ll j=0;
    for(ll i=0;i<m && j<n;i++)
    {
        ll ta=v[i].fi;

        ll va=v[i].se;
j+=va;
        while(va--)p.eb(ta);

    }

   // for(auto x:p)cout<<x<<" ";cout<<endl;

    ll sum=0;
    j=0;
    ll len=p.size();
    for(ll i=0;i<n;i++)
    {
    if(len>j)
        {
           if(p[j]>ara[i])
            {
                sum+=p[j];
                j++;
            }else {

                sum+=ara[i];
            }

        }else sum+=ara[i];
    }

    cout<<sum<<endl;




}


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

namespace ConsoleApplication1
{
    using System;
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            var inputs = Console.ReadLine().Split(' ');
            var a = int.Parse(inputs[0]);
            var b = int.Parse(inputs[1]);

            var result = OddOrEven(a, b);
            //出力
            Console.WriteLine(result);

            Console.ReadLine();
        }

        private static string OddOrEven(int i1, int i2)
        {
            return ((i1 % 2 == 0) || (i2 % 2 == 0)) ? "Even" : "Odd";
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

  double w, h, x, y;
  cin >> w >> h >> x >> y;
  ld all = w * h, ans = all / 2;
  string div = " ";
  if (w / 2 == x && h / 2 == y) {
    div += "1";
  } else if ((w / 2 == x || h / 2 == y || (x == 0 && y == 0) ||
              (x == 0 && h == y) || (x == w && h == 0) || (x == w && h == y))) {
    div += "0";
  } else if (y == 0) {
    div += "0";
  } else if (x == 0) {
    div += "0";
  } else {
    div += "0";
  }
  cout << fixed << setprecision(12) << ans << div << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long k = scan.nextLong();

        BitSet set = new BitSet();
        long[] array = new long[100000 + 1];
        for (int i = 0; i < n; ++i) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            array[a] += b;
            set.set(a);
        }

        for (int i = set.nextSetBit(0);; i = set.nextSetBit(i + 1)) {
            k -= array[i];
            if (k <= 0) {
                System.out.println(i);
                break;
            }
        }
    }

}

Measured memory_bytes: 64588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6

//Given a Weighted Directed Acyclic Graph and a source vertex in the graph, 
//find the shortest paths from given source to all other vertices.

// For a general weighted graph, we can calculate single source shortest distances(SSSD) in O(VE) time using Bellman–Ford Algorithm.
// For a graph with no negative weights, we can do better and calculate SSSD in O(E + VLogV) time using Dijkstra’s algorithm.
// We can do even better for Directed Acyclic Graph (DAG). We can calculate SSSD in O(V+E) time for DAGs.

int indegree[mxsize+5];
vector<pair<int,ll>> adj[mxsize+5];
vector<int> tsort;
vector<ll> dis(mxsize+5,INT_MIN);
void kahn(int n){
    queue<int> q;       // you can use priority queue if you want lexicographically smaller or larger
    
    for(int i=1;i<=n;i++){  //change here if node are 0 based
        if(indegree[i]==0){
            q.push(i);
            dis[i]=0;
        }
    }

    while(!q.empty()){
        int cur=q.front();
        // db(cur);nl;
        // tsort.push_back(cur);
        q.pop();
        for(auto p:adj[cur]){
            int node=p.first;
            indegree[node]--;
            if(indegree[node]==0){
                q.push(node);
                // if(dis[node]<1)    dis[node]=1;
                if(dis[p.F]<dis[cur]+1){
                    dis[p.F]=dis[cur]+1;
                }
            }
            
        }
    }
    // For a DAG, there always exists a Toposort
}

void fun(){
    int n;  // number of nodes
    int k;  // number of edges
    cin>>n>>k;

    fi(0,k){
        int x,y;
        ll w=1;
        cin>>x>>y;

        adj[x].push_back({y,1});
        indegree[y]++;
    }
    
    kahn(n);
    
    ll ans=0;
    fi(1,n+1){
        // db(dis[i]);
        ans=max(ans,dis[i]);
    }
    cout<<ans<<"\n";

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 37964
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	sort(arr.begin(),arr.end());
	ll mid = n/2;
	cout << arr[mid]-arr[mid-1] << endl;
}

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

int L[100005],R[100005],n,w[100005];
long long ans;
int main(){
	cin>>n;
	int x;
	for (int i=1;i<=n;i++){
		cin>>x;
		w[x]=i;
		L[i]=i-1;
		R[i]=i+1;
	}
	
	for (int i=1;i<=n;i++){
		int b=L[w[i]],a=L[b];
		int c=R[w[i]],d=R[c];
		if (b!=0) ans+=1ll*(b-a)*(c-w[i])*i;
		if (c!=n+1) ans+=1ll*(d-c)*(w[i]-b)*i;
		
		L[c]=b;
		R[b]=c;
	}
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7, INF = 0x3f3f3f3f;
int dp[1000010][2];

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s; cin >> s; s = '0' + s;
	vector<int> v;
	for(int i = 0; i < s.size(); ++ i){
		v.push_back(s[i] - '0');
	}
	int n = v.size();
	dp[0][0] = 0; dp[0][1] = 11;
	for(int i = 1; i < n; ++ i){
		dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + v[i];
		dp[i][1] = min(dp[i - 1][0] + 1, dp[i - 1][1] - 1) + 10 - v[i];
	}
	cout << min(dp[n - 1][0], dp[n - 1][1]) << '\n';
	return 0;
}

Measured memory_bytes: 15172
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N, M = rl()
Q = []
for i in range(M):
	x, y, z = rl()
	x, y = x-1, y-1
	Q.append((x, y, z))

ids = [i for i in range(N)]
def find(x):
	if x != ids[x]:
		p = find(ids[x])
		ids[x] = p
	return ids[x]

def unite(x, y):
	x = find(x)
	y = find(y)
	ids[x] = y

for x, y, z in Q:
	unite(x,y)
for i in range(N):
	find(i)
print(len(Counter(ids)))


Measured memory_bytes: 313784
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// readi Scannerから1単語取り出して数値に変換して取得する
func readi(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func absub(a, b int) int {
	if a < b {
		return b - a
	}
	return a - b
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	H := readi(sc)
	W := readi(sc)

	// fetch A
	A := make([][]int, H)
	for i := 0; i < H; i++ {
		A[i] = make([]int, W)
		for j := 0; j < W; j++ {
			A[i][j] = readi(sc)
		}
	}
	// fetch B
	B := make([][]int, H)
	for i := 0; i < H; i++ {
		B[i] = make([]int, W)
		for j := 0; j < W; j++ {
			B[i][j] = readi(sc)
		}
	}

	// 経路上のマスの偏り合計が取り得る最大値
	// = 経路マス数 : 縦マス数 H + 横マス数 W - 縦横マス重複分 1）
	// * 各マスの偏りが取り得る最大値 : 数字最大値 80 - 数字最小値 0
	M := (H + W - 1) * 80

	// マス(i,j)までの経路の偏りがkになることがあるかどうか
	dp := make([][][]bool, H)
	for i := 0; i < H; i++ {
		dp[i] = make([][]bool, W)
		for j := 0; j < W; j++ {
			dp[i][j] = make([]bool, M+1)
		}
	}

	// 開始点の偏りを設定する
	as, bs := A[0][0], B[0][0]
	ks := abs(as - bs)
	dp[0][0][ks] = true

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			for k, possible := range dp[i][j] {
				if !possible { // マス(i,j)までの偏り合計がkになり得ない場合
					continue
				}
				if i+1 < H { // 下隣のマス(i+1,j)がある場合
					au, bu := A[i+1][j], B[i+1][j]
					ku := abs(au - bu)
					dp[i+1][j][k+ku] = true
					dp[i+1][j][abs(k-ku)] = true
				}
				if j+1 < W { // 右隣のマス(i,j+1)がある場合
					ar, br := A[i][j+1], B[i][j+1]
					kr := abs(ar - br)
					dp[i][j+1][k+kr] = true
					dp[i][j+1][abs(k-kr)] = true
				}
			}
		}
	}

	// 目的地到着時の偏り最小値を求める
	ans := M
	for k, possible := range dp[H-1][W-1] {
		if possible {
			ans = k
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 64256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  REP(i,n){
    if ((i + 1) % 2 == 1 && a[i] % 2 == 1) ans++;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3596
S = [int(x) for x in input()]
for i in range(1 << len(S)-1):
    s = S[0]
    ans = str(S[0])
    for j in range(len(S)-1):
        if ((i >> j) & 1):
            s += S[j+1]
            ans += "+" + str(S[j+1])
        else:
            s -= S[j+1]
            ans += "-" + str(S[j+1])
    if s == 7:
        print(ans + "=7")
        break


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

int main(){
  int n,m,ma[100010],h[100001];
  cin >> n >> m;
  for(int i=1;i<=n;i++){
    cin >> h[i];
    ma[i] = 0;
  }
  for(int i=1;i<=m;i++){
    int a,b;
    cin >> a >> b;
    
    ma[a] = max(ma[a],h[b]);
    ma[b] = max(ma[b],h[a]);
  }
  
  int count = 0;
  
  for(int i=1;i<=n;i++){
    if(ma[i]<h[i]){
      count++;
    }
  }
  
  cout << count << endl; 
    
}
  



Measured memory_bytes: 4348
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = { 0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = { 0, 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

long long power_mod(long long x, long long n, long long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return power_mod(x * x % m, n / 2, m);
	else
		return x * power_mod(x, n - 1, m) % m;
}

long long power(long long a, long long n) {//aのn乗を計算します。
	long long x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}



long long nCr(long long n, long long r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	long long i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += power(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}


ll dp[100010];
int h[100010];
int main() {
	int N; cin >> N;
	REP(i, N)cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	FOR(i, 2, N) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	print(dp[N - 1]);
}


Measured memory_bytes: 1408
D=int(input())
c=list(map(int,input().split()))
s = [list(map(int,input().split())) for l in range(D)]
#print(s)
 
last=[0 for i in range(26)]
 
for i in range(D):#i日目
  best=0
  sat=0
  for j in range(26):#jを開催
    tempsat=0
    tempsat+=s[i][j]
    templast=last[j]
    last[j]=i
    for k in range(26):
      tempsat-=c[k]*(i-last[k])
    if(sat<=tempsat):
      sat=tempsat
      best=j
    last[j]=templast
  print(best+1)

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
 
/*
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)*/
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
 
/*
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;
 
const int MOD = 1e9+7;
const int INF = 1e9;*/
 
int main() {
	string S;
	int K;
	cin>>S>>K;
	int N = S.size();
	vector<string> vs;
 
    //n文字の中のk文字を探す
	for (int i = 0; i < N; ++i){
		for (int j = 0; i+j <= N&& j <=K; ++j){
			vs.push_back(S.substr(i,j));
		}
	}
 
	set<string> ss(all(vs));//全ての文字列のStringを構成
	vector<string> vs2(all(ss));//文字列をvector化する
	sort(all(vs2));//文字列を昇順にソート
	cout<<vs2[K]<<endl;
}

Measured memory_bytes: 2428
#include <stdio.h>

int main(void) {
    int a, b, k;
    int i;
    scanf("%d%d%d", &a, &b, &k);
    for(i=a; i<a+k && i<=b; i++)
        printf("%d\n", i);
    for(i=i>b-k+1?i:b-k+1; i<=b; i++)
        printf("%d\n", i);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
int n;
  cin>>n;
  string ans = "No";
  while(n>=0){
    if(n%4==0){
      ans = "Yes";
      break;
    }
    n-= 7;
  }
cout<<ans<<endl;

  return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	// freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	int ans = 0;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		ans += x - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def examA():
    N = I()
    ans = N + N**2 + N**3
    print(ans)
    return

def examB():
    S = SI()
    T = SI()
    ans = 0
    for s,t in zip(S,T):
        if s!=t:
            ans += 1
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  cout << 1110-n << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    int A, B, C, D;
    long[][] DP;
    long MOD = 998244353;
    long solve(int a, int b) {
        if(DP[a][b] != -1) {
            return DP[a][b];
        }
        long v = 0;
        boolean leftA = (C - a) > 0;
        boolean leftB = (D - b) > 0;
        if(leftA) {
            v += b*solve(a+1, b);
        }
        if(leftB) {
            v += a*solve(a, b+1);
        }
        if(leftA && leftB) {
            v -= (a*b)*solve(a+1, b+1);
        }
        long ov = v;
        v = (v%MOD + MOD)%MOD;
        DP[a][b] = v;
        return v;

    }
    void solve(BufferedReader in) throws Exception {
        int[] xx = toInts(in.readLine());
        A=xx[0];B=xx[1];C=xx[2];D=xx[3];
        DP = new long[C+1][D+1];
        for(int i = 0; i<=C;i++){
            for(int j = 0; j<=D; j++){
                DP[i][j] = -1;
            }
        }
        DP[C][D] = 1;
        for(int i = C-1; i>=A; i--) solve(i, B);
        System.out.println(solve(A, B));
    }
    int toInt(String s) {return Integer.parseInt(s);}
    int[] toInts(String s) {
        String[] a = s.split(" ");
        int[] o = new int[a.length];
        for(int i = 0; i<a.length; i++) o[i] = toInt(a[i]);
        return o;
    }
    void e(Object o) {
        System.err.println(o);
    }
    public static void main(String[] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        (new Main()).solve(in);
    }
}


Measured memory_bytes: 97456
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

const double pi = 3.14159265358979323846;
signed main()
{   
    int n;
    cin>>n;
    cout<<(n*(n+1))/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll ppow(ll a, ll n){
  ll t = n;
  ll res = 1;
  while(t > 0){
    if(t & 1) res = res * a;
    a = a * a;
    t >>= 1;
  }
  return res;
}

int main(){
  ll h; cin >> h;
  ll t = h;
  ll cnt = 0;
  while(h>0){
    h /= 2;
    cnt++;
  }
  cout << ppow(2,cnt) - 1 << endl;
  return 0;
}

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

int main(){ 
    int m,a,b;
    cin>>m>>a>>b;
    int c=0;
    int d=0;
    for(int n=1;n<=m;n++){
    if(n<10){
        c=n;
    }else if(n<100){
        c=n/10+n%10;
    }else if(n<1000){
        c=n/100+n/10%10+n%10;
    }else if(n<10000){
        c=n/1000+n/100%10+n/10%10+n%10;
    }else{
        c=1;
    }
    if(c>=a&&c<=b){
    d+=n;
    }
    }
    cout<<d;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(){
	int h, n, cont=0, eq=0;
	scanf("%d %d", &h, &n);
	int vet[n];
	for(int i=0; i<n; ++i){
		scanf("%d", &vet[i]);
		eq+=vet[i];
	}
	cont= eq-h;
	
	if(cont>=0)
		printf("Yes");
	else
		printf("No");
	printf("\n");
	return 0;
	
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
	while(1){
		int a;
		scanf("%d",&a);
		if(!a)break;
		int b=0,c=0;
		for(int i=0;i<a;i++){
			int d,e;
			scanf("%d%d",&d,&e);
			if(d>e)b+=d+e;
			else if(d==e){b+=d;c+=e;}
			else c+=d+e;
		}
		printf("%d %d\n",b,c);
	}
}



Measured memory_bytes: 2556
#include <iostream>
#include <string>
#define ll long long 
using namespace std;
int main() {
	ll x;
	cin>> x;
	bool flag=false;
	for (ll a=-200;a<=200;a++) {
		for (ll b=-200;b <=200;b++){
			if ((a*a*a*a*a - b*b*b*b*b )== x){
				cout << a << " "<< b << "\n";
				flag=true;
				break;
			}
		}

		if(flag){
			break;
		}
	}
	
}

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

int main()
{
	int S, W;

	

	cin >> S>>W;

	string result = "unsafe";

	if (S > W)result = "safe";





	
	cout << result<< endl;
}



int hyoe() {

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll D[10] = {};
ll K;
bool check(ll n) {
	ll t = n;
	bool ok = false;
	while (t > 0) {
		ll c = t % 10;

		rep(i, 0, K) {
			if (D[i] == c) {
				ok |= true;
			}
		}
		if (ok)break;

		t /= 10;
	}
	return ok;
}

int main() {
	ll N; cin >> N >> K;
	rep(i, 0, K)cin >> D[i];

	ll p = N;
	while (check(p)) {
		p++;
	}
	cout << p << endl;

	return 0;
}

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

using namespace std;

int main(){
  
  char S[3];
  char T[3];
  
  for(int i = 0; i < 3; i++) cin >> S[i];
  for(int i = 0; i < 3; i++) cin >> T[i];
  
  int cnt = 0;
  
  for(int i = 0; i < 3; i++) {
    if (S[i] == T[i]) cnt++;
  }
  
  cout << cnt;
  
 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N;
int A[200];

int main(){
    cin >> N;
    for(int i=0; i < N; i++) cin >> A[i];
    int res = 0;
    while(true){
        bool exist_odd = false;
        for(int i = 0; i<N; i++){
            if(A[i]%2 != 0) exist_odd = true;
        }
        if(exist_odd) break;
        for(int i = 0; i < N; i++){
            A[i]/=2;
    }
        res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 19, Mod = 1e9 + 7;
ll n;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ll tot = 0;
    ll m = n - 1;
    for (ll i = 1; i * i <= m; i ++)
        if (m % i == 0)
        {
            if (i != 1)
                tot ++;
            if (m / i != i)
                tot ++;
        }
    vector < ll > A;
    for (ll i = 1; i * i <= n; i ++)
        if (n % i == 0)
        {
            A.push_back(i);
            if (n / i != i)
                A.push_back(n / i);
        }
    for (ll a : A)
    {
        if (a == 1)
            continue;
        ll tmp = n, c = 0;
        while (tmp % a == 0)
            tmp /= a, c = 1;
        if (c == 0)
            continue;
        if (tmp % a == 1)
            tot ++;
    }
    printf("%lld\n", tot);
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, W;

signed main() {
    cin >> N >> W;

    vector<int> w1, w2, w3, w4;
    int w, v;
    cin >> w >> v;
    w1.push_back(v);
    REP(i, N - 1) {
        int tw, tv;
        cin >> tw >> tv;
        if (tw == w) w1.push_back(tv);
        if (tw == w + 1) w2.push_back(tv);
        if (tw == w + 2) w3.push_back(tv);
        if (tw == w + 3) w4.push_back(tv);
    }
    sort(w1.begin(), w1.end(), greater<int>());
    sort(w2.begin(), w2.end(), greater<int>());
    sort(w3.begin(), w3.end(), greater<int>());
    sort(w4.begin(), w4.end(), greater<int>());

    int ans = 0;
    REP(i, w1.size() + 1)
    REP(j, w2.size() + 1)
    REP(k, w3.size() + 1)
    REP(l, w4.size() + 1) {
        if (w * i + (w + 1) * j + (w + 2) * k + (w + 3) * l > W) continue;

        int tans = 0;
        REP(m, i) tans += w1[m];
        REP(m, j) tans += w2[m];
        REP(m, k) tans += w3[m];
        REP(m, l) tans += w4[m];
        ans = max(ans, tans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int h[10];
  for (int i = 0; i < 10; i++) {
    cin >> h[i];
  }
  sort(h, h+10);
  for (int i = 9; i >= 7; i--) {
    cout << h[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3044
/* ***********************************************
Author        :ACagain
Created Time  :2018/4/21 11:50:24
File Name     :dong.cpp
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define pii pair<int,int>
#define mp make_pair
#define ll long long
#define INF 0x3f3f3f3f
const int maxn=105;
char s[maxn],t[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	cin>>s>>t;
	int len1=strlen(s),len2=strlen(t);
	sort(s,s+len1);
	sort(t,t+len2);
	if(s[0]==s[len1-1]&&t[0]==t[len2-1])
	{
		if(len1<len2)
		  cout<<"Yes"<<endl;
		else
		  cout<<"No"<<endl;
	}
	else if(s[0]<t[len2-1])
	  cout<<"Yes"<<endl;
	else
	  cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LIN(N)
    A_ = sorted(A,reverse = True)
    A_1 = A_[0]
    A_2 = A_[1]
    for a in A:
        if a == A_1:
            print(A_2)
        else:
            print(A_1)
    



if __name__ == '__main__':
    main()

Measured memory_bytes: 60112
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int chain = 0;
        int prev = 0;
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(a != prev){
                ans += chain/2;
                chain = 1;
                prev = a;
            }else{
                chain++;
            }
        }
        
        System.out.println(ans + chain/2);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    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;
    } 
}


Measured memory_bytes: 21076
/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';
 
ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}
 

void solve(){   
    //clock_t time;
    int n; cin>>n;
    vi v(n), dp(n);
    for(int &i: v) cin>>i;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2; i<n; i++){
        dp[i]=min(abs(v[i]-v[i-1])+dp[i-1], abs(v[i]-v[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];
}
int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(9);
    
    //int t; cin>>t; while(t--) solve();    
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

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

S = raw_input()
length = len(S)
N = 7

def dfs(depth, S):

    if depth == length - 1:
        if eval(S) == N:
            print S + "=" + str(N)
            return True

        else:
            return False

    # 「-」を入れる場合
    if dfs(depth + 1, insert_minus(S, depth)):
        return True

    # 「+」を入れる場合
    if dfs(depth + 1, insert_plus(S, depth)):
        return True

    return False

def insert_plus(S, depth):
    d = depth + S.count("+") + S.count("-") + 1
    return "{0}{1}{2}".format(S[:d],"+",S[d:])

def insert_minus(S, depth):
    d = depth + S.count("+") + S.count("-") + 1
    return "{0}{1}{2}".format(S[:d],"-",S[d:])

dfs(0,S)

Measured memory_bytes: 2692
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

int n,ans=0;
vi num,tmp;
set<int> s;

int main(){
	cin>>n;
	num=vi(n);
	tmp=vi(n);
	for(int i=0;i<n;i++){
		cin>>num[i];
		tmp[i]=num[i];
	}
	sort(tmp.begin(),tmp.end());
	for(int i=1;i<n;i+=2) s.insert(tmp[i]);
	for(int i=1;i<n;i+=2){
		if(s.find(num[i])==s.end()) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#define max 50000
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int i;
	vector<int> cost(n+1,max),coin(m+1);
	cost[0]=0;
	for(i=0;i<m;++i){
		cin>>coin[i];
	}
	for(i=0;i<m;++i){
		for(int j=0;j+coin[i]<=n;++j){
			cost[j+coin[i]]=min(cost[j+coin[i]],cost[j]+1);
		}
	}
	cout<<cost[n]<<endl;
	return 0;
}


Measured memory_bytes: 3188
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 08, 2020 2:24 PM
 *    Problem Name  : D - Caracal vs Monster
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc153/tasks/abc153_d
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    ll h;
    cin >> h;

    ll ans = 0, cnt=1;

    while(h>0){
        h/=2;
        ans += cnt;
        cnt *= 2;
    }

    cout << ans << endl;

    return 0 ;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}

/*?????¬??????TOP?????????????????¢?????????*/
/*TOP??¨BOTTOM???FRONT?????????????????¢?????????*/
/************/
/*  0       */
/*  1 3 4 2 */
/*  5       */
/************/
class Cube{
public:
  struct cdat{char num[3][3];};
  const int TOP = 0, FRONT = 1, LEFT = 2;
  const int RIGHT = 3, BACK = 4, BOTTOM = 5;
  cdat cube[6];

  void rot(string cmd){
    if(cmd == "N") rotN();
    else if(cmd == "E") rotE();
    else if(cmd == "S") rotS();
    else if(cmd == "W") rotW();
    else if(cmd == "CW") rotCW();
    else if(cmd == "CCW") rotCCW();
    else exit(1);
  }

  void pr(){
    map<int,string> M;
    M[0] = "TOP",M[1] = "FRONT",M[2] = "LEFT";
    M[3] = "RIGHT", M[4] = "BACK", M[5] = "BOTTOM";
    for(int i=0;i<6;i++){
      cout<<M[i]<<endl;
      for(int j=0;j<3;j++){
        for(int k=0;k<3;k++)cout<<cube[i].num[j][k];
        cout<<endl;
      }
    }
  }

  void rot90(cdat &a){
    cdat b = a;
    for(int i=0;i<3;i++)
      for(int j=0;j<3;j++) a.num[i][j] = b.num[2-j][i];
  }
  void reverseX(cdat &a){for(int i=0;i<3;i++) reverse(a.num[i],a.num[i]+3);}
  void reverseY(cdat &a){rot90(a),reverseX(a),rot90(a),rot90(a),rot90(a);}
  

  void rotN(){  //?\\?????¢??????
    swap(cube[TOP],cube[FRONT]);
    swap(cube[FRONT],cube[BOTTOM]);
    swap(cube[BOTTOM],cube[BACK]);
    rot90(cube[TOP]),rot90(cube[TOP]);
    rot90(cube[BOTTOM]),rot90(cube[BOTTOM]);
    rot90(cube[LEFT]),rot90(cube[LEFT]),rot90(cube[LEFT]);
    rot90(cube[RIGHT]);
  }


  void rotCCW(){  //??????????????????????¨???????????????????
    swap(cube[FRONT],cube[LEFT]);
    swap(cube[LEFT],cube[BACK]);
    swap(cube[BACK],cube[RIGHT]);
    rot90(cube[TOP]),rot90(cube[TOP]),rot90(cube[TOP]);
    rot90(cube[BOTTOM]);
  }
  
  void rotE(){rotCCW();rotN();rotCW();}//????????¢??????
  void rotS(){rotN(),rotN(),rotN();}//???????????¢??????
  void rotW(){rotE(),rotE(),rotE();}//????????¢??????
  void rotCW(){rotCCW(),rotCCW(),rotCCW();}//???????????????????¨????????????????
};

Cube C;
const int TOP = 0, FRONT = 1, LEFT = 2;
const int RIGHT = 3, BACK = 4, BOTTOM = 5;


bool check(const Cube &c){
  bool front=0,back=0;
  for(int i=0;i<3;i++) front |= c.cube[FRONT].num[2][i] == '*';
  for(int i=0;i<3;i++) back |= c.cube[BACK].num[2][i] == '*';
  return front && back;
}

string dir[] = {"N","E","S","W"};
int ans;
void dfs(int dep){
  if(check(C)) ans = dep;
  if(ans <= dep) return;
  for(int i=0;i<4;i++){
    C.rot(dir[i]);
    dfs(dep+1);
    C.rot(dir[(i+2)%4]);
  }
}

signed main(){
  while(1){
    int ord[]={FRONT,RIGHT,BACK,LEFT,TOP,BOTTOM};
    for(int i=0;i<6;i++)
      for(int j=0;j<3;j++)
        for(int k=0;k<3;k++){
          char ch;
          cin>>ch;
          if(ch == '#') return 0;
          C.cube[ord[i]].num[j][k] = ch;
        }

    
    C.rot90(C.cube[TOP]);
    C.rot90(C.cube[TOP]);

    ans = 10;
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3068
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		call(sc.nextInt());
	}

	public static void call(int n){
		for(int i = 1;i <= n; i++){
			if(i % 3 == 0){
				System.out.printf(" %d",i);
			}else if(i % 10 == 3){
				System.out.printf(" %d", i);
			}else if(0 <= String.valueOf(i).indexOf('3')){
				System.out.printf(" %d", i);
			}
		}
		System.out.println();
	}
}




Measured memory_bytes: 39984
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

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

int main(void){
	int n,i;
	string s;
	cin >> s;
	n = s.l_ength()-1;
	n /= 2;
	for(i=n; i>0; --i){
		if(s.substr(0,i) == s.substr(i,i)){
			cout << (2*i) << endl;
			break; 
		}
	}
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

readString = map BS.unpack . BS.words

getIntList = readIntList <$> BS.getLine

getString = readString <$> BS.getLine

trim [] _ _ = ""
trim (c : cs) x x'
  | x' == 0 = c : trim cs x (x -1)
  | otherwise = trim cs x (x' -1)

main = do
  [n, m] <- getIntList
  [s] <- getString
  [t] <- getString
  let g = gcd n m
  let n' = n `div` g
  let m' = m `div` g
  print $ if trim s n' 0 == trim t m' 0 then g * n' * m' else (-1)


Measured memory_bytes: 5256
#include<iostream>
using namespace std;
 
typedef long long int ll;
typedef pair<ll,ll> P;
 
int main(){
    int n;
    cin>>n;
    int a,b,c;
    a=n%10;
    n/=10;
    b=n%10;
    n/=10;
    c=n%10;
    if(a==7||b==7||c==7){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
 
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

bool check(const std::string& ss, const std::string& t){
    for(int i=0; i<t.size(); i++){
        if(ss[i]==t[i]) continue;
        if(ss[i]=='?')  continue;
        return 0;
    }
    return 1;
}

int main(){
    std::string s,t;
    std::cin >> s >> t;

    if(s.size()<t.size()){
        std::cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    std::reverse(s.begin(),s.end());
    std::reverse(t.begin(),t.end());

    bool flag = false;
    for(int i=0; i<s.size()-t.size()+1; i++){
        std::string ss = s.substr(i,t.size());
        if(check(ss,t)){
            s.replace(i,t.size(),t);
            flag = true;
            break;
        }
    }

    if(flag==false){
        std::cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    std::reverse(s.begin(),s.end());
    for(int i=0; i<s.size(); i++){
        if(s[i]=='?') s[i]='a';
    }
    std::cout << s << "\n";
    return 0;
}

Measured memory_bytes: 3604