akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N,P;
    cin >> N>> P;
    map<ll,ll> num;
    for(ll i = 2;i * i <= P;i++){
        while(P % i == 0){
            P /= i;
            num[i]++;
        }
    }
    if(P != 1)num[P]++;
    ll ans = 1;
    for(auto x : num){
        ll n = x.second / N;
        rep(i,n)ans *= x.first;
    }
    cout << ans << endl;
}

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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
LL n;
vector<LL> arr;
vector<LL> res;
vector<LL> ans;
int main() {
	off;
	cin>>n;
	arr.resize(n+1);
	res.resize(n+1);
	rep(i,1,n+1)
	{
		cin>>arr[i];
		// if(i>= ((n+1)/2))
		// 	res[i]=arr[i];
	}
	// LL lim = (n+1)/2 - 1;
	for(LL i=n;i>=1;i--)
	{
		LL sum = 0;
		for(LL j=2*i;j<=n;j=j+i)
		{
			sum += res[j];
		}
		sum = sum%2;
		res[i]=arr[i]^sum;
	}
	rep(i,1,n+1)
	{
		if(res[i])
			ans.push_back(i);
	}
	cout<<ans.size()<<"\n";
	rep(i,0,ans.size())
	cout<<ans[i]<<" ";

  	return 0;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    set<int> a;
    int tmp;
    int other = 0;

    rep(i,0,N) {
        cin >> tmp;

        if (tmp<400) {
            a.insert(0);
        }
        else if (tmp < 800) {
            a.insert(1);
        }
        else if (tmp < 1200) {
            a.insert(2);
        }
        else if (tmp < 1600) {
            a.insert(3);
        }
        else if (tmp< 2000) {
            a.insert(4);
        }
        else if (tmp < 2400) {
            a.insert(5);
        }
        else if (tmp < 2800) {
            a.insert(6);
        }
        else if (tmp < 3200) {
            a.insert(7);
        }
        else {
            other++;
        }
    }

    if (a.size()==0) {
        cout << 1 << " " << other << endl;
    }
    else {
        cout << a.size() << " " << a.size()+other << endl;
    }

}



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

int main()
{
    int N;
    vector<int> h;
    vector<int> cost;

    cin >> N;
    h.resize(N);
    cost.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);

    for (int i = 2; i < N; i++)
    {
        cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << cost[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
#include <queue>
#include <vector>
//#define ULL unsigned long long
#define ULL long long
#define MOD 1000000007
//#define log
//#define logshowBoard
//#define logShowError
 
using namespace std;

ULL Pow(ULL a, ULL n){
	if(n==0){
		return 1;
	}
	if(n%2){
		return a*Pow(a, n-1) % MOD;
	}else{
		ULL x = Pow(a, n/2);
		return (x*x) % MOD;
	}
}
ULL NiYuan(ULL a){
	return Pow(a, MOD-2);
}
ULL C(ULL n, ULL a){
	a = min(a, n-a);
	ULL fenzi = 1;
	ULL fenmu = 1;
	for(int i=0; i<a; i++){
		fenzi *= n-i;
		fenzi %= MOD;
		fenmu *= i+1;
		fenmu %= MOD;
	}
	return ( (fenzi%MOD) * (NiYuan(fenmu)%MOD)) % MOD ;
}
int main()
{
	ULL n,a,b;
	while(cin>>n>>a>>b){
//		ULL ans = Pow(2, n) - 1 - C(n, a) - C(n, b);
		ULL P = Pow(2, n) - 1;
		ULL CA = C(n, a);
		ULL CB = C(n, b);
		ULL ans = P-CA-CB;
//		printf("%lld - %lld - %lld = %lld\n", P, CA, CB, ans);
//		cout << P << " - " << CA << " - " << CB << " = " <<  ans << endl;//
		while(ans<0){
			ans += MOD;
		}
		cout << (ans%MOD) << endl;
	}
		
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int a, b, c;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b >> c;
        a *= a;
        b *= b;
        c *= c;
        if (a + b == c || b + c == a || c + a == b)
            cout << "YES";
        else 
            cout << "NO";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(2*10**5)
n=int(input())
G=[[]for i in range(n+1)]
for i in range(n-1):
    a, b, c = map(int,input().split())
    G[a] += (b,c),
    G[b] += (a,c),
q, k = map(int,input().split())
d = [0]*(n+1) #kから各点への距離
def f(v,p,u): #v:今見ているとこ p:一つ前に見たとこ u:kからの距離
    d[v] = u
    for t, c in G[v]:
        if p != t:
            f(t,v,u+c)
f(k,0,0)
for i in range(q):
    x, y = map(int,input().split())
    print(d[x]+d[y])

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

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

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

  int n; cin >> n;
  ll a;
  int odd = 0;
  rep(i, n) {
    cin >> a;
    if(a&1) odd++;
  }

  cout << (odd&1 ? "NO" : "YES") << '\n';
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        if(n+m >= a){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
package main

import "fmt"

func main() {
	var (
		n    int
		s, t string
	)
	fmt.Scan(&n, &s, &t)

	if s == t {
		fmt.Println(len(s))
		return
	}

	ans := s + t
	for i := 1; i < n; i++ {
		if s[len(s)-i:] == t[:i] {
			ans = s + t[i:]
		}
	}
	fmt.Println(len(ans))
}


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

#define MAXN 110

using namespace std;

int n;
int b[MAXN];
vector<int> res;

int main() {
    scanf("%d", &n);
    int i, j;
    for (i=1; i<=n; i++) {
        scanf("%d", &b[i]);
    }
    int pode = 1;
    while (n>0) {
        for (i=n; i>=1; i--) {
            if (b[i]==i) {
                //printf("** %d\n", b[i]);
                res.push_back(i);
                for (j=i; j<=n-1; j++) {
                    b[j]=b[j+1];
                }
                n--;
                break;
            }
        }
        if (i==0) {
            pode = 0;
            break;
        }
    }
    if (pode==0) {
        printf("-1\n");
    }
    else {
        for (i=res.size()-1; i>=0; i--) {
            printf("%d\n", res[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}


template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<Pll> a(n);
    rep(i,n){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(all(a), greater<Pll>());
    // vector dp(n+1, vector<ll>(n+10));
    // rep(i,n){
    //     ll num = a[i].first, id = a[i].second;
    //     rep(j,i+1){
    //         chmax(dp[i+1][j+1], dp[i][j] + num * abs(id - j));
    //         chmax(dp[i+1][j], dp[i][j] + num * abs(n - i + j - 1 - id));
    //     }
    // }
    // print(dp);

    // インライン化
    vector<ll> dp2(n+1);
    rep(i,n){
        ll num = a[i].first, id = a[i].second;
        rrep(j,i+1){
            chmax(dp2[j+1], dp2[j] + num * abs(id - j));
            chmax(dp2[j], dp2[j] + num * abs(n - i + j - 1 - id));
        }
        // print(dp2);
    }
    ll ans = 0;
    rep(i,n+1)chmax(ans, dp2[i]);
    cout << ans << endl;
}

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

int main(){
  long long W,H,N,x,e,f,g;
  cin>>N;
  g=0;
 vector<long long>a(3*N);
  for(int i=0;i<3*N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
    for(int i=0;i<2*N;i++){
   if(i%2==1){
     g+=a[i];
   }
  }
    cout<<g<<endl;
}

Measured memory_bytes: 2560
using System;

public class ABC137_A {
    private static void Main(string[] args) {
        var inputs = Console.ReadLine().Trim().Split();
        var h = double.Parse(inputs[0]);
        var a = double.Parse(inputs[1]);

		var answer = Math.Ceiling(h / a);
		Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int a[MAX];

int main() {
   int n;
    cin >> n;
    REP(i, n){
      int x;
      cin >> x;
      a[x]++;
    }
    int one = 0, two =0;
    FOR(i,1,MAX-1){
      if(a[i]%2) one++;
      else if(a[i] > 0)two++;
    }
    if(two%2 == 0){
      cout << one+two <<endl;
    }
    else{
      cout << one-1+two <<endl;
    }
    return 0;
}

Measured memory_bytes: 768
import java.util.*;import java.io.*; class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); 	int x = sc.nextInt(); 	int t = sc.nextInt(); 	PrintWriter out = new PrintWriter(System.out); out.println(Math.max(x - t, 0)); 	out.flush(); }}class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;} public boolean hasNext() { skipUnprintable(); return hasNextByte();} public int nextInt() { if (!hasNext()) throw new NoSuchElementException(); int n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } }}

Measured memory_bytes: 20564
// abc176_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  for (int i = 0, cnt = (int)N.size(); i<cnt; ++i) {
    ans += (int)N[i] - '0';
  }

  //cout << ans << endl;
  if(ans%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 20001;
ll a,b,ans=0;

int main(){
	cin>>a>>b;
	string s="11111";
	FOR(i,a,b+1){
		ll j=i;
		ll k=0;
		while(j){
			s[k]=j%10;
			j/=10;
			k++;
		}
		if(s[0]==s[4]&&s[1]==s[3])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    string a,b;
    cin>>a>>b;
    int ctr=0;
    for(int i=0;i<3;i++)
    {
        if(a[i]==b[i])
            ctr++;
    }
    cout<<ctr;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] a = { 1, 2, 4, 8, 16, 32, 64 };
        int p = int.Parse(Console.ReadLine());
        Console.WriteLine(a.TakeWhile(x => p >= x).Last());
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll;
int main ()
{
 ll N ;
cin >> N;
for(int i = 1; i <= 9; i++){
       if(111 * i >= N){
           cout << 111 * i << endl;
           break;
       }}


return 0 ;
}



Measured memory_bytes: 256
H,W = map(int,input().split())

s = [list(input()) for y in range(H)]

for y in range(H):
    for x in range(W):
        if s[y][x]=="#":
            enable = False
            if x-1>=0 and s[y][x-1]=="#":
                enable=True
            if x+1<W and s[y][x+1]=="#":
                enable=True
            if y-1>=0 and s[y-1][x]=="#":
                enable=True
            if y+1<H and s[y+1][x]=="#":
                enable=True
            if enable==False:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 66228
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
MOD = 1000000007
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()
    A = LI()

    # color_number[i][j]: [0, i)でj番目に多い色の人数
    color_number = [[0, 0, 0] for _ in range(N)]
    for i in range(N-1):
        if A[i] in color_number[i]:
            idx = color_number[i].index(A[i])
        else:
            idx = -1
        for j in range(3):
            if j==idx:
                color_number[i+1][j] = color_number[i][j] + 1
            else:
                color_number[i+1][j] = color_number[i][j]

    ans = 1
    for i in range(N):
        ans *= color_number[i].count(A[i])
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 20724
#coding:utf-8
import sys
import bisect
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    a, b  = LMIIS()

    if 1 <= a <= 9 and 1 <= b <= 9:
        print(a*b)
    else:
        print("-1")



if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e6)

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==1) return m;
	ll ans=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) ans=ans*m%mod;
	return ans;
}

ll binom(ll n, ll k){
	ll a=1, b=1;
	for(ll i=0; i<k; i++){
		a=a*(n-i)%mod;
		b=b*(k-i)%mod;
	}
	return a*pmod(b, mod-2)%mod;
}

int main(){
	int n;
	cin >> n;
	vector<int> c;
	for(int i=1; i<=n; i*=6) c.push_back(i);
	for(int i=1; i<=n; i*=9) c.push_back(i);
	c.erase(unique(c.begin(), c.end()), c.end());

	int d[n+1];
	for(int i=0; i<=n; i++) d[i]=i;
	for(int i=0; i<=n; i++){
		for(int j=0; j<c.size(); j++){
			if(i>=c[j]){
				d[i]=min(d[i], d[i-c[j]]+1);
			}
		}
	}
	cout << d[n] << endl;
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

struct edge{ int to, cap, rev, alive; };

vector<edge> G[500];
bool used[500];

void add_edge(int from, int to, int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size(),true});
  G[to].push_back((edge){from,cap,(int)G[from].size()-1,true});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0; i < G[v].size(); i++){
    edge &e=G[v][i];
    if(!e.alive)continue;
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t,int lim){
  int flow=0;
  while(lim>0){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,lim);
    if(f==0)break;
    flow+=f;
    lim-=f;
  }
  return flow;
}

int N,M,Q;

int main(){
  cin>>N>>M>>Q;
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--;b--;
    add_edge(a,b,1);
  }
  int src=0,sink=N-1;
  int crtf=max_flow(src,sink,INF);
  while(Q--){
    int t,u,v;
    cin>>t>>u>>v;
    u--;v--;
    if(t==1){
      add_edge(u,v,1);
      crtf+=max_flow(src,sink,1);
      cout<<crtf<<endl;
    }else{
      rep(i,G[u].size()){
        if(G[u][i].to==v&&G[u][i].alive){
          G[u][i].alive=false;
          if(G[u][i].cap==0&&max_flow(u,v,1)==0){
            max_flow(u,src,1); max_flow(sink,v,1);
            crtf-=1;
          }
          break;
        }
      }
      rep(i,G[v].size()){
        if(G[v][i].to==u&&G[v][i].alive){
          G[v][i].alive=false;
          if(G[v][i].cap==0&&max_flow(v,u,1)==0){
            max_flow(v,src,1); max_flow(sink,u,1);
            crtf-=1;
          }
          break;
        }
      }
      cout<<crtf<<endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int m=100,n;
	cin>>n;
	
	for(int i=0;i<n;i++)m=ceil(m*1.05);
	
	cout<<m<<"000"<<endl;
	return 0;
}

Measured memory_bytes: 0
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
a=list(map(int,stdin.readline().split()))
poss=True
for i in a:
    if(i%2==0):
        if(i%3!=0 and i%5!=0):
            poss=False
            break
if(poss):
    print("APPROVED")
else:
    print("DENIED")

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

int main() {
	int r, d, x2000;
	cin >> r >> d >> x2000;
	int xi = x2000;

	rep(i, 10) {
		xi = r * xi - d;
		cout << xi << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) ll((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
const ll MOD = 1E9+7;
const ll INF = 1E18;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=1e5+5;
int n,m;
bool vst[N];
vector<int> adj[N];

void dfs(int u){
	vst[u]=true;
	for(int v:adj[u])
		if(!vst[v]) dfs(v);
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	REP(i,m){
		int u,v,c;
		cin>>u>>v>>c;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int res=0;
	FOR(i,1,n) if(!vst[i]) dfs(i),++res;
	cout<<res<<'\n';
}



Measured memory_bytes: 12184
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int ans = 1;
int mod = 1;
int hai[500] = {0};
int main(){
	int i, j, k;
	cin >> n >> m;
	if(n % (2 * m + 1) == 0)mod =  0;
	cout << n / (2 * m + 1) + mod;
	return 0;
}

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

const ll MOD = 1e9 + 7;

int mpow(int base, int exp);
typedef  vector<int> vi;
typedef  vector<ll> vll;
typedef  vector<pair<ll,ll>> vpll;
typedef  vector<pair<int, int>> vpii;
typedef  pair<int, int> pii;
typedef  pair<ll, ll> pll;
typedef  unordered_map<ll, ll> umpll;
typedef  unordered_map<int, int> umpii;
typedef  unordered_map<ll, int> umpli;
typedef  unordered_set<int> usi;
typedef  unordered_set<ll> usll;
typedef  set<int> si;
typedef  set<ll> sll;
typedef  set<pair<int, int>> spii;
typedef  set<pair<ll, ll>> spll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fo(i,n) for(i = 0;i < n; i++)
#define Fo(i,k,n) for(i = k;k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", "<< #z << " = " << z << endl

ll randGen(ll lower, ll upper) { return (rand() % (upper - lower + 1)) + lower; }
ll dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);
//******************          Function here          *********************//

   void solve(){
      string s;
      cin >> s;
      int sum = 0;
      for(int i = 0; i < s.size(); i++) {
         sum += (s[i] - '0');
      }
      if(sum % 9 == 0) cout << "Yes\n";
      else cout << "No\n";
    }

//*********************************************************************//

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, outputFile;
      inputFile = "input.txt";
      outputFile = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(outputFile.c_str(), "w", stdout);
    #endif

    int t = 1;
    // cin>>t;
    while(t-- >0){
      solve();
    }
    return 0;
}



/**********************   Utility Functions  *****************************/
   int mpow(int base, int exp) {
     base %= MOD;
     int result = 1;
     while (exp > 0) {
       if (exp & 1) result = ((ll)result * base) % MOD;
       base = ((ll)base * base) % MOD;
       exp >>= 1;
     }
     return result;
   }
/***********************************************************************/


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const ld EPS = 1e-8;

ll f(ll b, ll n) {
  if(n < b) return n;
  else return f(b, n / b) + (n % b);
}

ll solve(ll n, ll s) {
  if(n == s) return n + 1LL;
  for(ll b = 2LL; b * b <= n; ++b) {
    if(f(b, n) == s) return b;
  }
  ll res = INF;
  for(ll p = 1LL; p * p <= n; ++p) {
    if(n % p != s % p) continue;
    ll b = (n - s) / p + 1LL;
    if(b < 2LL) continue;
    if(f(b, n) == s) res = min(res, b);
  }
  if(res < INF) return res;
  return -1LL;
}

int main(){
  ll n, s;
  cin >> n >> s;
  cout << solve(n, s) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    string s;
    int Q;
    cin >> s >> Q;
    vector <string> str(2);
    str[1] = s;
    int rev = 0;
    for (int i=0; i<Q; i++) {
        int T,F;
        string C;
        cin >> T;
        rev = (rev + T)%2;
        if (T==2) {
            cin >> F >> C ;
            str[(F-1 + rev)%2] = str[(F-1 + rev)%2] + C;
        }
    }
    reverse(str[rev].begin(),  str[rev].end()); 
    cout << str[rev] << str[(rev+1)%2] << endl;
    return 0;
}

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

typedef long long ll;
#define pb push_back
#define ii pair<int ,int >
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const double eps = 1e-9;

int main()
{
	IO;
	ll x;
	cin>>x;
	ll ans=(x/500LL)*1000LL;
	x%=500;
	ans+=(x/5)*5;
	cout<<ans<<endl;
}

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

void dfs(string &s, string sub,
    vector<string> &result, map<char,bool> &changed){
    if(s.size() == sub.size()){
        result.push_back(sub);
        return;
    }
    char c = s[sub.size()];
    if(!changed[c] && c!='z'){
        changed[c] = true;
        dfs(s,sub+char(c+1),result,changed);
        changed[c] = false;
    }
    if(changed[c-1] || c=='a'){
        dfs(s,sub+char(c),result,changed);
    }
}

int main(void){
    string s;
    while(cin>>s, s!="#"){
        vector<string> result;
        map<char,bool> changed;
        dfs(s,"",result,changed);
        sort(all(result));
        int m = result.size();
        cout<<m<<endl;
        rep(i,m){
            if(i<5 || m-5<=i) cout<<result[i]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4212
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

N,Q=map(int,input().split())
graph=[[]for _ in range(N)]
point=[0]*N
for _ in range(N-1):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
for _ in range(Q):
    a,b=map(int,input().split())
    a=a-1
    point[a]=point[a]+b

def dfs(now,prev=-1):
    for i in graph[now]:
        if i==prev:
            continue
        point[i]=point[i]+point[now]
        dfs(i,now)
dfs(0)
print(*point)

Measured memory_bytes: 268432
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
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<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int h,w;

int main(){
	cin>>h>>w;
	char c='A';
	int I=1;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		string s;
		cin>>s;
		if(s=="snuke"){
			c+=j;
			I+=i;
		}
	}
	cout<<c<<I<<endl;
}

Measured memory_bytes: 256
s = input()
b = True
a1 = 0
a2 = 0
for i in range(len(s)):
    if s[i] != ("0" if b else "1"):
        a1 += 1
    if s[i] != ("1" if b else "0"):
        a2 += 1
    b = not b
print(min(a1, a2))


Measured memory_bytes: 3188
#define VERNIY st();int ver=0,niy=0,hbk=0
#define HIBIKI int ver=0,niy=0,hbk=0
//#pragma GCC optimize("0fast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
typedef unsigned long long LLU;
typedef long long LL;
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
typedef vector<int> vd;
typedef vector<pair<int,int> > vpd;
typedef pair<int,int> pd;
typedef queue<int> qd;
typedef queue<pair<int,int> > qpd;
typedef priority_queue<int> maxpqd;
typedef priority_queue<int, vector<int>, greater<int> > minpqd;
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; ++a)
#define forineq(a,b,c) for(int a=b ; a<=c ; ++a)
#define forde(a,b,c) for(int a=b ; a>=c ; --a)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')
#define filein(oo) freopen(oo,"r",stdin);
#define fileout(oo) freopen(oo,"w",stdout);
#define setarr(a,b,c) memset(a,b,sizeof(c))

template<class Ver>
inline void in(Ver &a){cin>>a;}
template<class Ver,class Niy>
inline void in(Ver &a, Niy &b){cin>>a>>b;}
template<class Ver,class Niy, class Hbk>
inline void in(Ver &a, Niy &b, Hbk &c){cin>>a>>b>>c;}

template<class Ver>
inline void out(Ver a){cout<<a<<"\n";};
template<class Ver,class Niy>
inline void out(Ver a,Niy b){cout<<a<<" "<<b<<"\n";};
template<class Ver,class Niy, class Hbk>
inline void out(Ver a, Niy b, Hbk c){cout<<a<<" "<<b<<" "<<c<<"\n";};

inline void debug(){cout<<"asd"<<endl;}
template<class Ver>
inline void debug(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver,class Niy>
inline void debug(Ver a,Niy b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver,class Niy, class Hbk>
inline void debug(Ver a,Niy b,Hbk c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define grav 9.8
#define pi 3.14159265

void st()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main()
{
	VERNIY;
/*	HIBIKI;
	filein("in.txt");
	fileout("out.txt");
*/
	in(ver,niy);
	if(niy%ver==0)
	out(ver+niy);
	else
	out(niy-ver);
	return 0;
}


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

using ll = long long;
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	if (n < m)
		std::swap(n, m);
	if (2 <= n - m) {
		printf("%d\n", 0);
	} else if (n - m == 1) {
		ll Pattern_n, Pattern_m = 1, Pattern;
		for (int i = 2; i <= m; i++)
			Pattern_m = Pattern_m * i % 1000000007;
		Pattern_n = Pattern_m * n % 1000000007;
		Pattern = Pattern_n * Pattern_m % 1000000007;
		printf("%d\n", Pattern);
	} else if (n - m == 0) {
		ll Pattern = 1;
		for (int i = 2; i <= n; i++)
			Pattern = Pattern * i % 1000000007;
		Pattern = Pattern * Pattern * 2 % 1000000007;
		printf("%d\n", Pattern);
	}
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,X,Y,Z; cin >> N >> X >> Y >> Z;
	vector<LL> dp(1<<(X+Y+Z),0);
	dp[0] = 1;
	const LL mod = 1e9+7;
	repp(i,0,N){
		vector<LL> nx(1<<(X+Y+Z),0);
		repp(k,0,1<<(X+Y+Z)) repp(w,1,11){
			int a = (((k&((1<<X)-1))<<w)|(1<<(w-1)))&((1<<X)-1);
			int b = ((k&((1<<(X+Y))-(1<<(X-1))))<<w)&((1<<(X+Y))-(1<<X));
			int c = ((k&((1<<(X+Y+Z))-(1<<(X+Y-1))))<<w)&((1<<(X+Y+Z))-(1<<(X+Y)));
			(nx[a^b^c|(k&(1<<(X+Y+Z-1)))] += dp[k]) %= mod;
		}
		swap(dp,nx);
	}
	LL ans = 0;
	repp(k,1<<(X+Y+Z-1),1<<(X+Y+Z)) (ans += dp[k]) %= mod;
	cout << ans << endl;
	return 0;
}


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

int main() {
  map<string, int> mp;
  int N, M;
  cin >> N;
  for(int i=0;i<N;i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> M;
  for(int i=0;i<M;i++) {
    string s;
    cin >> s;
    mp[s]--;
  }

  ll ans = 0;
  for(auto itr = mp.begin();itr != mp.end(); ++itr) {
    ans = max<ll>(ans, (*itr).second);
  }
  cout << ans << endl;


}


Measured memory_bytes: 256
/* AOJ 0032
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0032
 */

#include <stdio.h>


int main(){
  int first, second, diagonal;
  int rect, loze;

  rect = 0;
  loze = 0;
  while(scanf("%d,%d,%d", &first, &second, &diagonal)==3){
    if(diagonal < first + second){
      if(diagonal*diagonal == first*first + second*second){
        rect += 1;
      }else{
        if(second == first){
          loze += 1;
        }
      }
    }
  }
  printf("%d\n", rect);
  printf("%d\n", loze);
  return 0;
}

Measured memory_bytes: 0
import math
D, G = map(int, input().split())

P = []; C = []
for i in range(D):
    pi, ci = map(int, input().split())
    P.append(pi)
    C.append(ci)

max_cnt = sum(P)

def solve(i, score, cnt, nm):
    if i == D:
        if score >= G:
            return cnt
        else:
            add_cnt = (G-score)/((nm+1)*100)
            if add_cnt > P[nm]:
                return max_cnt
            else:
                return cnt + int(math.ceil(add_cnt))
    return min([solve(i+1, score+P[i]*(i+1)*100 + C[i], cnt+P[i], nm), 
                solve(i+1, score, cnt, i)])

a = solve(0, 0, 0, 0)
print(a)

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
 
 int main()
 {
  ll n;
  cin>>n;
  vector<ll>h;
  for(ll i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    h.pb(x);
  }  ll dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(ll i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
 }

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a[4];
    for(int i=0;i<4;i++)cin>>a[i];
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)cout << "YES"<<endl;
    else cout << "NO" <<endl;
    return 0;
}


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

int main() {

    int n;
    cin >> n;
    set<int> used;
    used.insert(n);
    bool flag = false;
    int fl = 1;
    while (!flag) {
        // cout << n << endl;
        if (n % 2 == 0) {
            n = n / 2;
        }
        else {
            n = 3 * n + 1;
        }
        int pr = used.size();
        used.insert(n);
        flag = (used.size() == pr);
        fl++;
    }
    cout << fl << endl;

}

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

int main(){
	int m,n,money,y,A,tmp,sum,r,mx;
	double rate;
	cin >> m;
	
	while(m--){
		cin >> money >> y >> n;
		mx = 0;
		for(int i=0;i<n;i++){
			cin >> r >> rate >> A;
			tmp = money;
			sum = 0;
			if(!r){
				for(int i=0;i<y;i++){
					sum += tmp*rate ;
					tmp -= A;
				}
				mx = max(mx,sum+tmp);
			}else{
				for(int i=0;i<y;i++){
					tmp += tmp*rate ;
					tmp -= A;
				}
				mx = max(mx,tmp);
			}
		}
		cout << mx << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;



int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());
	string tar;
	cin >> tar;
	string s;
	int cnt = 0;
	while(cin >> s)
	{
		transform(s.begin(), s.end(), s.begin(), ::tolower);
		if(s == tar) ++cnt;
		if(s == "END_OF_TEXT")break;
	}

	cout << cnt << endl;
	
	return 0;
}




Measured memory_bytes: 3176
package main

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

func main() {
	scanInit()

	n := nextInt()
	p := make([]pair, n)

	for i := 0; i < n; i++ {
		x := nextInt()
		l := nextInt()
		p[i] = pair{x + l, x - l}
	}

	sortPairs(p)

	cnt := 1
	last := p[0].f
	for i := 1; i < n; i++ {
		// startがlastよりも未満だったらスルー
		if p[i].s < last {
			continue
		}

		last = p[i].f
		cnt++
	}

	fmt.Println(cnt)

}

// Pair ソート
// s := make([]pair, n)
// sortPairs(s)
type pair struct { // f=first, s=second
	f int
	s int
}

// []pair をf->sの順でソートする
func sortPairs(s []pair) {
	sort.Slice(s, func(i, j int) bool {
		if s[i].f == s[j].f { // fが同じ場合はsを比較する
			return s[i].s < s[j].s
		}
		return s[i].f < s[j].f
	})
	return
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int n, m;
int main() {
  cin >> n >> m;
  if (n % 2 == 1) {
    for (int i = 0; i < m; ++i) {
      cout << i + 1 << ' ' << n - i << endl;
    } 
  } else {
    for (int i = 0; i < min(m, n / 4); ++i) {
      cout << i + 1 << ' ' << n - i << endl;
    }
    for (int i = n / 4; i < m; ++i) {
      cout << i + 1 << ' ' << n - i - 1 << endl;
    }
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>


long long s,c;
long long solve(void);

int main(int argc, const char * argv[]) {
    scanf("%lld %lld",&s, &c);
    printf("%lld",solve());
    return 0;
}

long long solve(void){
    if(c >= s*2){
        c -= s*2;
        return s + c/4;
    }else{
        return c/2;
    }
}


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

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

int N, M, m[1010], s[1010];

int main() {	
	while (cin >> N >> M, N) {
		for_(i,0,N) cin >> m[i];
		for_(i,0,M) cin >> s[i];
		
		int cur = 0;
		
		for_(i,0,M) {
			cur += s[i];
			
			if (cur >= N - 1) {
				cout << i + 1 << endl;
				break;
			}
			
			cur += m[cur];			
			
			if (cur >= N - 1) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1168
#include "bits/stdc++.h"
using namespace std;

#define MAX 100002

char buf[MAX];

string s;

int main() {
	scanf("%s", buf);
	s = "0";
	s += buf;
	s += "0";
	vector<int> id;
	for (int i = 0; i + 1 < s.size(); i++) {
		if (s[i] != s[i + 1]) {
			id.push_back(i);
		}
	}
	int mint = s.size()-2;
	for (int i = 0; i < id.size(); i++) {
		mint = min(mint, max((int)(s.size()-2) - id[i], id[i]));
	}
	cout << mint << endl;
	return 0;
}

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

#define ll long long

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  ll n = s.size();
  ll i;
  ll k;
  cin >> k;
  for(i=0;i<n;i++)
  {
    if(s[i]== s[0])
    {
    }
    else
    {
      break;
    }
  }
  if(i==n)
  {
    cout << (k*n)/2 << endl;
    return 0;
    
    
  }
  
  {
    if(s[0] == s[n-1])
    {
      ll sum = 0;
      ll fr,bk,mx,rst;
      
      char x = s[0];
      i = 0;
      while(s[i] == x)
      {
        i++;
      }
      fr = i;
      i=0;
      while(s[n-1-i] == x)
      {
        i++;
      }
      bk = i;
      mx = bk + fr;
      for(i=fr;i<=(n-1-bk);)
      {
        x = s[i];
        ll cnt = 0;
        while(s[i]==x)
        {
          cnt++;
          i++;
          
        }
        rst += (cnt /2);
        
      }
      sum += (rst *k);
      sum += (fr/2);
      sum += (bk/2);
      sum += (k-1)*(mx/2);
      cout << sum << endl;
      
    }
    else
    {
      ll rst= 0;
      for(i=0;i<n;)
      {
        char x = s[i];
        ll cnt = 0;
        for(;(x==s[i])&&(i<n);i++)
        {
          cnt++;
        }
        rst += (cnt / 2);
      }
      cout << (rst*k) << endl;
      
    }
  }
  return 0;
}

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

using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b&&a>c){
		cout<<(b*c)/2<<endl;
	}else if(b>a&&b>c){
		cout<<(a*c)/2<<endl;
	}else{
		cout<<(a*b)/2<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s; cin >> s;
	if(count(s.begin(), s.end(), 'B') and count(s.begin(), s.end(), 'A')) println("Yes");
	else println("No");
}


Measured memory_bytes: 256