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

struct edge{
  int to, num;
};

int n, m;
vector<edge> G[N];
int A, B, minuscost;

int used[N], cost[N];

int dfs(int x){
  
  if(used[x]) return 0;
  used[x]=1;
  
  int res=0;
  
  for(int i=0;i<G[x].size();i++){
    if(A==G[x][i].num) continue;
    if(B==G[x][i].num) continue;
    res+=dfs(G[x][i].to);
  }
  
  return res+1;
}

void solve(){
  
  memset(used,0,sizeof(used));
  
  A=-1, B=-1;
  
  int nodesum=dfs(0);
  
  if(nodesum!=n){
    cout<<minuscost<<endl;
    return ;
  }
  
  int ans=(1e9);
  
  for(int i=0;i<m;i++){
    A=i;
    for(int j=i+1;j<m;j++){
      B=j;
      memset(used,0,sizeof(used));
      int r=dfs(0);
      if(r!=n) ans=min(ans, cost[A]+cost[B]+minuscost);
    }
    B=-1;
    memset(used,0,sizeof(used));
    int r=dfs(0);
    if(r!=n) ans=min(ans, cost[A]+minuscost);
  }
  
  cout<<ans<<endl;
}

int main(){

  while(1){
  
    cin>>n>>m;
    if(!n&&!m) break;
    
    minuscost=0;
  
    int cnt=0;
  
    for(int i=0;i<m;i++){
      int x, y, c;
      cin>>x>>y>>c;
      if(c<=0){
	minuscost+=c;
	continue;
      }
      cost[cnt]=c;
      G[x].push_back((edge){y,cnt});
      G[y].push_back((edge){x,cnt++});
    }

    m=cnt;
  
    solve();

    for(int i=0;i<n;i++) G[i].clear();
  }
  
  return 0;
}

Measured memory_bytes: 3144
N, K = map(int, input().split())
S = input();

mans = [];
seq = 0;
now = S[0];
if(now == "0"):
    mans.append(0);

for i in S:
    if(i == now):
        seq += 1;
    else:
        mans.append(seq);
        seq = 1;
        if(now=="1"):
            now="0"
        else:
            now="1"

if(seq!=0):
    mans.append(seq);
    if(now=="1"):
        now="0"
    else:
        now="1"
if(now=="0"):
    mans.append(0);

mans.append(0);

shakutori = [0]
shakunum = 0;

for i in mans:
    shakunum += i;
    shakutori.append(shakunum);

if(len(shakutori) <= 2*K+1):
    print(shakutori[-1]);
else:
    answer = 0;
    for i in range(1,len(shakutori),2):
        if(len(shakutori) <= i+2*K):
            break;
        else:
            if(shakutori[i+2*K]-shakutori[i-1] > answer):
                answer = shakutori[i+2*K]-shakutori[i-1];
    print(answer);


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int k; cin >> k;
    int a, b; cin >> a >> b;

    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[] s = br.readLine().toCharArray();
		int q = Integer.parseInt(br.readLine());
		List<TreeSet<Integer>> list = new ArrayList<>(26);
		for (int i = 0; i < 26; i++) {
			list.add(new TreeSet<>());
		}
		for (int i = 0; i < n; i++) {
			int b2 = s[i] - 'a';
			list.get(b2).add(i);
		}
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			String[] sa = br.readLine().split(" ");
			if ("1".equals(sa[0])) {
				int a = Integer.parseInt(sa[1]) - 1;
				int b1 = s[a] - 'a';
				int b2 = sa[2].charAt(0) - 'a';
				s[a] = sa[2].charAt(0);
				list.get(b1).remove(a);
				list.get(b2).add(a);
			} else {
				int l = Integer.parseInt(sa[1]) - 1;
				int r = Integer.parseInt(sa[2]);
				int ans = 0;
				for (int j = 0; j < 26; j++) {
					TreeSet<Integer> set = list.get(j);
					Integer x = set.ceiling(l);
					Integer y = set.lower(r);
					if (x != null && y != null && x <= y) {
						ans++;
					}
				}
				pw.println(ans);
			}
		}
		br.close();
		pw.flush();
	}
}


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

int main() {
	int num = 1;
	int flg[100001] = { };
	flg[3] = 1;
	for(int i = 4; i < 100001; i++){
		if(i % 4 != 1){
			flg[i] = flg[i - 1];
		}
		else{
			int pf = 0;
			int n = (i + 1) / 2;
			unsigned int upper = sqrt(i);
				for(int j = 3; j <= upper; j += 2 ) if( !(i % j) ) pf = 1;
				for(int j = 3; j <= upper; j += 2 ) if( !(n % j) ) pf = 1;
			if(pf == 0) flg[i] = flg[i - 1] + 1;
			else flg[i] = flg[i - 1];
		}
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int q1, q2;
		cin >> q1 >> q2;
		int ans = flg[q2] - flg[q1 - 1];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    auto pf=prime_factorize(n);
    ll ans=0;
    for(auto p : pf){
        int x=p.second;
        int cnt=1;
        //cout<<x<<endl;
        while(true){
            ans++;
            cnt++;
            x-=cnt;
            if(x<=0) break;
        }
    }

    cout<<ans<<endl;
}

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

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int[] alpha = new int[26];

        while(in.hasNext()){
            char[] str = in.nextLine().toLowerCase().toCharArray();

            for(int i = 0; i < str.length; i++){
                if(str[i] >= 'a' && str[i] <= 'z')alpha[str[i] - 97]++;
            }
        }
        for(int i = 0; i < 26; i++){
            System.out.printf("%c : %d\n", i + 97, alpha[i]);
        }
    }
}


Measured memory_bytes: 26252
def resolve():
    n = int(input())
    next_button = list()

    for i in range(n):
        a = int(input())
        next_button.append(a)
    
    now_button = 1
    ans = 0
    for i in range(n):
        now_button = next_button[now_button-1]
        #print(f"{i} times now button is {now_button}")
        if now_button == 2:
            ans += 1
            break
        ans += 1

    if ans == n:
        print(-1)
    else:
        print(ans)
resolve()

Measured memory_bytes: 7084
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

main(){
	int a,b;
	cin>>a>>b;
	int sum=0;
	if(a==3)sum+=100000;
	if(a==2)sum+=200000;
	if(a==1)sum+=300000;
	if(b==3)sum+=100000;
	if(b==2)sum+=200000;
	if(b==1)sum+=300000;
	if(a==1 && b==1)sum+=400000;

	cout<<sum<<endl;
}




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

bool is_prime(long long n) {
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}

long long solve(long long X) {
    while (true) {
        if (is_prime(X)) return X;
        ++X;
    }
}

int main() {
    long long X;
    cin >> X;
    cout << solve(X) << endl;
}


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** .5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors

divs = make_divisors(m)
d = [x for x in divs if x >= n][0]
print(m // d)

Measured memory_bytes: 3064
from collections import deque
n = int(input())
edges = [[] for _ in range(n)]

for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == '1':
            edges[i].append(j)

#可能か
flg = True
l, r = set(), set()
l.add(0)
que = deque()
que.append((0, True))
is_left = True
while que and flg:
    cur, is_left = que.popleft()
    for to in edges[cur]:
        if is_left:
            if to in l:
                flg = False
            elif to not in r:
                r.add(to)
                que.append((to, False))
        else:
            if to in r:
                flg = False
            elif to not in l:
                l.add(to)
                que.append((to, True))

    if is_left:
        is_left = False
    else:
        is_left = True


if not flg:
    print(-1)

else:
    def warshall_floyd(d, v):
        for k in range(v):
            for i in range(v):
                for j in range(v):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    inf = 1000
    d = [[inf] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if j in edges[i]:
                d[i][j] = 1

    warshall_floyd(d, n)
    
    ans = 0
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            ans = max(ans, d[i][j]+1)

    print(ans)


Measured memory_bytes: 75012
#include <stdio.h>

#define NUM 100000

int main()
{
	int n = 0, data[NUM], i= 0,  min = 0, max = 0;
	long int sum = 0;
	
	scanf("%d", &n);
	
	while(1) {
		if (i == n) {
			break;
		}
		scanf("%d", &data[i]);
		i++;
	}
	min = max = data[0];
	
	
	i = 0;
	while(1) {
		if (i == n) {
			break;
		}
		sum = sum + data[i];
		
		if (min >= data[i]) {
			min = data[i];
		}
		
		if (max <= data[i]) {
			max = data[i];
		}
		i++;
	}
	
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}

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

void insertionSort(vector<int>& array);
void dump(vector<int>& array);

int main()
{
    int size;
    vector<int> array;

    cin >> size;
    for (int i = 0; i < size; i++) {
        int tmp;
        cin >> tmp;
        array.push_back(tmp);
    }
    insertionSort(array);
    return 0;
}

void insertionSort(vector<int>& array)
{
    dump(array);
    for (int i = 1; i < array.size(); i++) {
        int tmp = array[i];
        int j;
        for (j = i - 1; j >= 0; j--) {
            if (tmp < array[j]) {
                array[j + 1] = array[j];
            } else {
                break;
            }
        }
        array[j + 1] = tmp;
        dump(array);
    }
}

void dump(vector<int>& array)
{
    for (int i = 0; i < array.size(); i++) {
        cout << array[i];
        if (i < array.size() - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}

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

int main(){
  long long x,c,d;
  cin>>x;
  
  c=x/11;
  d=x%11;
  if(d==0){
    cout<<c*2<<endl;
  }else if(d<=5){
    cout<<c*2+1<<endl;
    return 0;
  }else if(d==6&&c%2==0){
    cout<<c*2+1<<endl;
  }else if(d>=6){
    cout<<c*2+2<<endl;
  }
}

Measured memory_bytes: 256
main = do
    l <- getLine
    let (w:h:x:y:r:[]) = map read $ words l :: [Int]
    putStrLn $ if overWidth w x r || overHeight h y r
                 then "No"
                 else "Yes"

overWidth :: Int -> Int -> Int -> Bool
overWidth w x r = (x - r < 0) || (w < x + r)

overHeight :: Int -> Int -> Int -> Bool
overHeight h y r = (y - r < 0) || (h < y + r)

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

int main() {
  int n;
  cin >> n;
  
  if (n<10)
    cout << n << endl;
  else if (n<100)
    cout << 9 << endl;
  else if (n<1000)
    cout << n-90 << endl;
  else if (n<10000)
    cout << 909 << endl;
  else if (n<100000)
    cout << n-9090 << endl;
  else
    cout << 90909 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  vector<bool> c(n);
  int cnt=0;
  for(int i=n-1;i>=0;i--){
    int sum=0;
    for(int j=2;(i+1)*j<=n;j++){
      if(c[(i+1)*j-1]){
        sum++;
      }
    }
    if(sum%2!=a[i]){
      c[i]=true;
      cnt++;
    }
  }
  cout << cnt << endl;
  for(int i=0;i<n;i++){
    if(c[i]){
      cout << i+1 << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 1792
import math

def main():
    X=int(input())

    for a in range(-120,120):
        flag=0
        for b in range(-120,120):
            if pow(a,5)-pow(b,5)==X:
                print("{} {}".format(a,b))
                flag=1
                break
        if flag==1:
            break

if __name__=="__main__":
    main()


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

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int num = 0;
	for (int i = 1; i < n; i++) if (s[i] == 'E') num++;
	int minnum = num;
	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'E') num--;
		if (s[i-1] == 'W') num++;
		minnum = min(minnum, num);
	}
	cout << minnum << endl;
	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n;
  cin >> n;
  ll x, y, a = 1, b = 1;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    ll j = max((a + x - 1) / x, (b + y - 1) / y);
    a = x * j;
    b = y * j;
  }
  cout << a + b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,s) for(int i=s;i>=0;--i)

using ll = long long;
using namespace std;

const ll INF = 1010101010;
const ll MOD = 1000000007;

int main() {
	int y = 0;
	string s, str, c;
	cin >> s >> str;
	rep(i, str.size()) {
		if (s == str) {
			cout << "Yes" << endl;
			return 0;
		}
		c = s[s.size() - 1];
		s.pop_back();
		s = c + s;
		if (s == str) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int card[], tmp[];
		int i, j;
		while(true){
			int n = sc.nextInt();
			int r = sc.nextInt();
			if(n == 0)
				break;
			card = new int[n];
			for(i = 1; i <= n; i++){
				card[n - i] = i;
			}
			for(i = 0; i < r; i++){
				int p = sc.nextInt();
				int c = sc.nextInt();
				tmp = new int[c];
				for(j = 0; j < c; j++){
					tmp[j] = card[p - 1 + j];
				}
				for(j = p - 2; j >= 0; j--){
					card[j + c] = card[j];
				}
				for(j = 0; j < c; j++){
					card[j] = tmp[j];
				}
			}
			System.out.printf("%d\n", card[0]);
		}
	}
}

Measured memory_bytes: 37332
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,n,m,p,ind;
	cin>>n;
	map<ll,ll>m1;
	fl(i,n-1) {
		cin>>j;
		m1[j]++;
	}
	fl(i,n) {
		cout<<m1[i+1]<<endl;
	}
}

int main() {
    speedup;
    ll i=0,t;
    //cin>>t;
    t=1;
    while(t--) {
        comp();
    }
    return 0;
}


Measured memory_bytes: 16120
import numpy as np


def main():
    As = [list(map(int, input().split())) for j in range(3)]
    As = np.array(As)
    n = int(input())
    bs = [int(input()) for i in range(n)]
    for b in bs:
        As = np.where(As == b, 0, As)

    if np.any(np.all(As == 0, axis=0)):
        print("Yes")
    elif np.any(np.all(As == 0, axis=1)):
        print("Yes")
    elif As[0][0] == 0 and As[1][1] == 0 and As[2][2] == 0:
        print("Yes")
    elif As[0][2] == 0 and As[1][1] == 0 and As[2][0] == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 21896
import qualified Data.List as L

toInt x = read x :: Int

nearX :: Int -> ([Int], [Int]) -> Int
nearX x ([], ys) = head ys
nearX x (xs, []) = last xs
nearX x (xs, ys) = if alxs <= alys  then lxs
                                    else lys
                where
                    lxs = last xs
                    lys = head ys
                    alxs = abs (x - lxs)
                    alys = abs (x - lys)

main = do
    xn <- map toInt . words <$> getLine
    pi <- map toInt . words <$> getLine
    let x = head xn
        pj = [0..101] L.\\ pi
        tupleP = span (<x) pj
    print $ nearX x tupleP

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    priority_queue<int> q;
    int N=in();
    int M=in();
    REP(i,N){
        int a;
        cin>>a;
        q.push(a);
    }
    REP(i,M){
        int now=q.top();q.pop();
        q.push(now/2);
    }
    ll ans=0;
    REP(i,N){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	sort(begin(s), end(s));
	
	if(s == "abc") printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))
(defmacro aif (test-form then-form &optional else-form)
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))
(defmacro read-str ()
  `(write-to-string (read)))

;;本体
(defun judge (lst)
  (every #'evenp lst))
(defvar n (read))
(defun main ()
  (do ((i 0 (1+ i))
       (a (loop for i below n collect (read))
          (mapcar (lambda (x) (/ x 2)) a)))
      ((not (judge a)) (println i))))

#-swank(main)


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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int a, b;
    cin >> a >> b;
    bool possible = false;
    if (a % 3 == 0) {
        possible = true;
    }
    if (b % 3 == 0) {
        possible = true;
    }
    if ((a+b) % 3 == 0) {
        possible = true;
    }
    (possible) ? cout << "Possible\n" : cout << "Impossible\n";
    return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush
INF = 10 ** 18

def dijkstra(s):
    used = [1] * n
    dp = [INF] * n
    dp[s] = 0
    hq = []
    used[s] = 0
    for i in cost[s]:
        heappush(hq, i)

    while hq:
        minv = heappop(hq)
        if used[minv[1]] == 0:
            continue
        v = minv[1]
        dp[v] = minv[0]
        used[v] = 0
        for i in cost[v]:
            if used[i[1]]:
                heappush(hq, [i[0] + dp[v], i[1]])
    return dp

n, u, v = map(int, input().split())
cost = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cost[a].append([1, b])
    cost[b].append([1, a])

dp1 = dijkstra(v - 1)
dp2 = dijkstra(u - 1)
ans = 0
for i in range(n):
    if dp1[i] >= dp2[i]:
        ans = max(ans, dp1[i])

print(ans - 1)

Measured memory_bytes: 48868
#include<stdio.h>

int main(){
  int a, b, c;
  scanf("%d %d %d", &a,&b,&c);
  if(a==5&&b==5&&c==7){
    printf("YES");
  }else if(a==5&&b==7&&c==5){
    printf("YES");
  }else if(a==7&&b==5&&c==5){
    printf("YES");
  }else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,n)
    ll a,minus=0,sum=0,absmin=MOD;
    rep(i,n){
        cin>>a;
        sum+=abs(a);
        if(a<0)minus++;
        chmin(absmin,abs(a));
    }
    minus%2==0?p(sum):p(sum-absmin*2);
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            String S = in.next();
            int ans = 0;

            for (int i = 1; i <= N - 1; i++) {
                String X = S.substring(0, i);
                String Y = S.substring(i);
                int cnt = 0;
                for (int j = 0; j < 26; j++) {
                    String tmp = String.valueOf((char) ('a' + j));
                    if (X.contains(tmp) && Y.contains(tmp)) cnt++;
                    ans = Math.max(ans, cnt);
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 24020
import java.util.Scanner;
import java.math.BigInteger;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    BigInteger n = sc.nextBigInteger(); 
    BigInteger b = sc.nextBigInteger(); 
    BigInteger r = sc.nextBigInteger();
    sc.close();
    if(b.equals(new BigInteger("0"))) {
      System.out.println("0");
    } else {
      BigInteger lp = b.add(r);
      BigInteger nDiv = n.divide(lp);
      BigInteger rem = n.mod(lp);
      BigInteger remMinRed = rem.subtract(r);
      BigInteger lpTimesBlue = nDiv.multiply(b);
      if(rem.compareTo(b) == 0) {
        System.out.println(lpTimesBlue);
      } else if(rem.compareTo(b) == 1) {
        System.out.println(lpTimesBlue.add(b));
      } else {
        System.out.println(lpTimesBlue.add(rem));
      }
    }
  }
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

const int mod = 1e9 + 7;
int n, m;
int R[301][4][2];
int dp[301][301][301];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= 3; ++j) R[i][j][0] = i, R[i][j][1] = 0;
    while (m--) {
        int l, r, x;
        cin >> l >> r >> x;
        R[r][x][0] = min(R[r][x][0], l);
        R[r][x][1] = max(R[r][x][1], l);
    }
    dp[0][0][0] = 1;
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (int k = 0; k <= i; ++k) {
                int pos = 1;
                {
                    int x = R[i][1][0];
                    int y = R[i][1][1];
                    if (y > 0 && (x <= i) + (x <= j) + (x <= k) != 1) pos = 0;
                    if (y > 0 && (y <= i) + (y <= j) + (y <= k) != 1) pos = 0;
                }
                {
                    int x = R[i][2][0];
                    int y = R[i][2][1];
                    if (y > 0 && (x <= i) + (x <= j) + (x <= k) != 2) pos = 0;
                    if (y > 0 && (y <= i) + (y <= j) + (y <= k) != 2) pos = 0;
                }
                {
                    int x = R[i][3][0];
                    int y = R[i][3][1];
                    if (y > 0 && (x <= i) + (x <= j) + (x <= k) != 3) pos = 0;
                    if (y > 0 && (y <= i) + (y <= j) + (y <= k) != 3) pos = 0;
                }
                if (pos == 0) {
                    dp[i][j][k] = dp[j][k][i] = dp[k][i][j] = 0;
                    continue;
                }
                if (i == n) {
                    ans += dp[i][j][k]; ans %= mod;
                    if (i == j && j == k) continue;
                    ans += dp[j][k][i]; ans %= mod;
                    ans += dp[k][i][j]; ans %= mod;
                }
                else {
                    dp[i + 1][j][k] += dp[i][j][k];
                    dp[i + 1][j][k] %= mod;
                    dp[i][i + 1][k] += dp[i][j][k];
                    dp[i][i + 1][k] %= mod;
                    dp[i][j][i + 1] += dp[i][j][k];
                    dp[i][j][i + 1] %= mod;
                    if (i == j && j == k) continue;
                    dp[i + 1][k][i] += dp[j][k][i];
                    dp[i + 1][k][i] %= mod;
                    dp[j][i + 1][i] += dp[j][k][i];
                    dp[j][i + 1][i] %= mod;
                    dp[j][k][i + 1] += dp[j][k][i];
                    dp[j][k][i + 1] %= mod;
                    dp[i + 1][i][j] += dp[k][i][j];
                    dp[i + 1][i][j] %= mod;
                    dp[k][i + 1][j] += dp[k][i][j];
                    dp[k][i + 1][j] %= mod;
                    dp[k][i][i + 1] += dp[k][i][j];
                    dp[k][i][i + 1] %= mod;
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 106752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N; cin >> N;
	vector<int> A(N, 0);
	rep (i, N){
		cin >> A[i];
	} // end rep

	vector<int> a; a.clear();
	a.push_back(A[0]);
	for (int i = 1; i < N; ++i){
		if (A[i-1] == A[i]){
			continue;
		}else{
			a.push_back(A[i]);
		} // end if
	} // end for

	int n = (int)a.size();
	int res = 0;
	if (n == 1){
		res = 1;
	}else{
		int left = 0;
		int right = 0;
		bool updown = (a[0] < a[1]); // up:= true down:= false
		while(right < n){
			if (updown){
				for (; right + 1 < n && a[right] < a[right + 1]; ++right);
				++res;
				++right;
				left = right;
				updown = (a[right] < a[right + 1]);
			}else{
				for (; right + 1 < n && a[right] > a[right + 1]; ++right);
				++res;
				++right;
				left = right;
				updown = (a[right] < a[right + 1]);
			} // end if
		} // end while
	} // end if

	cout << res << endl; 	
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n;
    cin >> n; // n偶数
    vi d(n);
    rep(i,n) {
        cin >> d[i];
    }
    sort(d.begin(),d.end());

    cout << d[n/2] - d[n/2-1];

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  ll n;
  cin >> n;
  vector<ll> A;
  for(ll i=0; i<n; i++){
    ll in;
    cin >> in;
    A.push_back(in);
  }
  sort(A.begin(), A.end());
  ll max = A[n-1];
  vector<ll>::iterator it1 = A.begin();
  while(*it1 <= floor(max/2) && it1 != A.end()) it1++;
  if(it1 != A.end()) it1--;
  vector<ll>::iterator it2 = A.end(); it2--;
  while(*it2 >= ceil(max/2) && it2 != A.begin()) it2--;
  if(it2 != A.begin()) it2++;

  ll cand1 = *it1;
  ll cand2 = *it2;
  if(max % 2 == 0){
    if(abs(cand1-max/2) <= abs(cand2-max/2)){
      cout << max << ' ' << cand1 << endl;
    } else {
      cout << max << ' ' << cand2 << endl;
    }
  } else {
    if(abs(cand1-(max-1)/2) <= abs(cand2-(max+1)/2)){
      cout << max << ' ' << cand1 << endl;
    } else {
      cout << max << ' ' << cand2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1400
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

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

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

int main(void)
{
	//変数の宣言
	int n,m;
	int x[100010];
	int kukan[100010];

	//よく使う変数
	int i,j,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	fri(m){
		scanf("%d",&x[i]);
//		scanf_s("%d",&x[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	qsort(x, m, sizeof(int), compare_up);
	
	fri(m-1){
		kukan[i]=x[i+1]-x[i];
	}

	qsort(kukan, m-1, sizeof(int), compare_down);

	fri(m-1){
		if(i>=n-1) ans=ans+kukan[i];
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%d",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 1268
import sys
n=int(input())
As = list(map(int, input().split()))
ans=1
for val in As:
    if val==0:
        ans=0
        break
for val in As:
    if ans==0:
        break
    if val==0:
        ans=0
        break
    ans=val*ans
    if 10**18<ans:
        ans=-1
        break

print(ans)

Measured memory_bytes: 21692
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(std::string S, std::string T){
    ll N = S.length();
    ll ans = 0;
    REP(i, N){
        if(S[i] != T[i]) ans ++;
    }
    cout<<ans<<endl;
}
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const int MOD = 1e9 + 7;

///********FILE READ AND WRITE*************************\\\

#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)

///----------------------------------------------------\\\

#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);


///**********************************************************************************\\\


int main()
{
    taratari

    int n;
    cin>>n;

    string x;

    int ac=0,wa=0,tle=0,re=0;

    while(n--)
    {
        cin>>x;

        if(x=="AC")
        {
            ac++;
        }

        if(x=="WA")
        {
            wa++;
        }

        if(x=="TLE")
        {
            tle++;
        }

        if(x=="RE")
        {
            re++;
        }
    }

    cout<<"AC"<<" x "<<ac<<endl;
    cout<<"WA"<<" x "<<wa<<endl;
    cout<<"TLE"<<" x "<<tle<<endl;
    cout<<"RE"<<" x "<<re;


    return 0;

}



Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = list(input())
	
	
	to = 0
	NN = ""
	for i in N:
		to += int(i)
		NN += i
	
	if int(NN) % to == 0:
		print("Yes")
	else:
		print("No")
	
	
if __name__ == "__main__":
	main()


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (s.size()%2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int i=0; i<(s.size()/2); i++) {
        if (s[i] != s[i+(s.size()/2)]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var H int
	var skillNum int
	var skill int
	fmt.Scan(&H)
	fmt.Scan(&skillNum)

	for i := 0; i < skillNum; i++ {
		fmt.Scan(&skill)
		H = H - skill
	}
	if H > 0 {
		fmt.Print("No")
	} else {
		fmt.Print("Yes")
	}
}


Measured memory_bytes: 6320
#include<bits/stdc++.h>
using namespace std;
int main(){
 int h,w;
 cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
        cin >> a[i][j];
    }
}
    for(int i = 0; i < h; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < w; k++){
                cout << a[i][k];
                if(k == w - 1)
                cout << endl;
            }
        }
    }
}

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

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var s = cin.NextString();
			s = s.Substring(0, s.Length - "FESTIVAL".Length);
			Console.WriteLine(s);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			new Template().Solve();
			Console.ReadLine();
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

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

// long long int chmin(long long int a, long long int b)
// {
// 	if (a > b)
// 		return b;
// 	else
// 		return a;
// }

void chmin(long long int a, long long int b, long long int *c)
{
	if (a > b)
		*c = b;
	else
		*c = a;
}

int main(int argc, char const *argv[])
{
	long long int n;
	scanf("%lld", &n);
	long long int *dp = malloc(n * sizeof(long long int));
	long long int *h = malloc(n * sizeof(long long int));
	for (int i = 0; i < n; i++)
	{
		dp[i] = 1000000;
		scanf("%lld", h+i);
	}
	dp[0] = 0;
	dp[1] = llabs(h[1] - h[0]);
	for (int i = 2; i < n; ++i)
	{
		//dp[i]=chmin(dp[i - 2] + llabs(h[i] - h[i - 2]), dp[i - 1] + llabs(h[i] - h[i - 1]), &dp[i]);
		chmin(dp[i - 2] + llabs(h[i] - h[i - 2]), dp[i - 1] + llabs(h[i] - h[i - 1]), &dp[i]);
	}
	free(h);
	printf("%lld", dp[n-1]);
	free(dp);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

void main_sub(void) {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    vector<int> q(n);
    rep(i, n) cin >> q[i];
    vector<int> v(n);
    rep(i, n) v[i] = i + 1;
    int a = -1;
    int b = -1;
    int cnt = 0;
    do {
        bool p_flag = true;
        bool q_flag = true;
        rep(i, n) {
            if (v[i] != p[i]) p_flag = false;
            if (v[i] != q[i]) q_flag = false;
        }
        if (p_flag) a = cnt;
        if (q_flag) b = cnt;
        cnt++;
    } while (next_permutation(all(v)));
    cout << abs(a - b) << endl;
    return;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int x,n;
    cin>>x>>n;
    map<int,int>m;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        m[a]=1;
    }
    int ans=5000;
    for(int i=0;i<200;i++)
    {
        int t1=x-i,t2=x+i;
        if(m[t1]==0)
        {
            ans=t1;
            break;
        }
        if(m[t2]==0)
        {
            ans=t2;
            break;
        }
    }
    cout<<ans;
  	return 0;
}







Measured memory_bytes: 3632
#include <iostream>
#include <string>
typedef long long LL;
using namespace std;

LL gcd(LL a, LL b){
    LL ans;
    LL tmp; 
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    ans = a * b;
    tmp = a%b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a%b;
    }
    ans = ans / b;
  
    return ans;
}

int main(){
    LL a;
    LL b;
    LL c;
    LL d;
    LL e;
    LL tmp;
    LL diff;
    LL sum = 0;   
    cin >> a >> b >> c >> d;
    if(a%c==0){
        diff = b - a;
    }else{
        diff = b - ((a/c) + 1) * c;
    }
    if(diff>=0){
        sum += (diff/c) + 1;
    }

    if(a%d==0){
        diff = b - a;
    }else{
        diff = b - ((a/d) + 1) * d;
    }
    if(diff>=0){
        sum += (diff/d) + 1;
    }

    e = gcd(c, d);
    //e = c * d;
  
    if(a%e==0){
        diff = b - a;
    }else{
        diff = b - ((a/e) + 1) * e;
    }
    if(diff>=0){
        sum -= (diff/e) + 1;
    }
    sum = b - a + 1 - sum;    
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b >= c)cout << b + c;
  else cout << a + b + b + 1;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a = int(a)
    b  = int(b)
    if op ==  "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)


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

using namespace std;

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		long long a, b, c, d;
		cin >> a >> b >> c >> d;
		auto p = (a + b) / (min(a, b) + 1);
		auto m = 0ll, n = a + 1;
		while (m + 1 < n) {
			auto x = (m + n) / 2;
			if ((a + 1 - x)*p < b - max(0ll, (x - 1) / p))
				n = x;
			else m = x;
		}
		n = m + max(0ll, (m - 1) / p);
		p++;
		string s;
		for (int i = c - 1; i < d; i++) {
			if (i < n) {
				if ((i + 1) % p) s += 'A';
				else s += 'B';
			}
			else {
				if ((a + b - i) % p) s += 'B';
				else s += 'A';
			}
		}
		cout << s << endl;
	}
	return 0;
}


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

void fnInput(int &rnLodC, int &rnTrkC, vector<int> &rvnLod)
{
  cin >> rnLodC >> rnTrkC;

  rvnLod.resize(rnLodC);
  for (int i = 0; i < rnLodC; i++)
    cin >> rvnLod[i];
}

int fnSimuAlloc(const vector<int> &cnrvnLod, int nTrkC, int nLod)
{
  int iCurLod;
  int iCntTrk = 0;

  for (int i = 0; i < cnrvnLod.size();    )
  {
    if (cnrvnLod[i] > nLod)  return 0;

    iCntTrk++;
    iCurLod = 0;
    while (i < cnrvnLod.size())
    {
      iCurLod += cnrvnLod[i];
      if (iCurLod > nLod)  break;

      i++;
    }
  }
  return (iCntTrk <= nTrkC);
}

void fnAlloc(const vector<int> &cnrvnLod, int nTrkC, int &rnMinLod)
{
  const int cnnMinLod = 0;
  const int cnnMaxLod = 1000000000;

  int nLow  = cnnMinLod;
  int nHigh = cnnMaxLod;
  rnMinLod = cnnMaxLod;

  while (nLow < nHigh)
  {
    int nMind = (nLow + nHigh) / 2;
    if (fnSimuAlloc(cnrvnLod, nTrkC, nMind))
    {
      rnMinLod = min(rnMinLod, nMind);
      nHigh = nMind;
    }
    else
      nLow = nMind + 1;
  }
}

void fnReSult(int nMinLod)
{
  cout << nMinLod << endl;
}

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

  int nLodC, nTrkC;
  vector<int> vnLod;
  int nMinLod = 0;

  fnInput(nLodC, nTrkC, vnLod);
  fnAlloc(vnLod, nTrkC, nMinLod);
  fnReSult(nMinLod);

  return 0;
}

Measured memory_bytes: 1524