akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(string s; cin >> s;) {
    if(s == "0") break;

    int n = s.size();
    rep(i, n) s[i] -= '0';

    static int dp[2][2][11];
    zero(dp);

    int ans = 0;

    rep(i, n) {
      zero(dp[(i+1)&1]);
      if(s[i] != 0) dp[(i+1)&1][1][(int)s[i]] ++;
      rep(usen0, 2) rep(j, 11) {
        bool nusen0 = usen0 || (s[i] != 0);
        int nj = (j * 10 + s[i]) % 11;
        dp[(i+1)&1][nusen0][nj] += dp[i&1][usen0][j];
      }
      ans += dp[(i+1)&1][1][0];
    }

    cout << ans << endl;

  }
  
  return 0;
}

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

n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
to = [[] for i in range(n)]

for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

ans = 0

for i in range(n):
    ok = True
    for j in to[i]:
        if(h[i] <= h[j]):
            ok = False
    if(ok):
        ans += 1

print(ans)


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

int main() {
    int H, W;
    cin >> H >> W;
    if (H>50 || W>50) exit(0);
    
    string S[60];
    for (int i=1; i<H+1; i++) {
        cin >> S[i];
        S[i] = "." + S[i]+".";
    }

    int M[60][60];
    for (int i=0; i<H+2; i++) {
        for (int j=0; j<W+2; j++) {
            if ((S[i])[j] == '#')M[i][j]=1;
            else M[i][j] = 0;
        }
    }
    
    int L[60][60];
    for (int i=1; i<H+1; i++) {
        for (int j=1; j<W+1; j++) {
            if (M[i][j]==0) {
            L[i][j] = M[i][j-1]+M[i][j+1]+M[i-1][j-1]+M[i-1][j]+M[i-1][j+1]+M[i+1][j-1]+M[i+1][j]+M[i+1][j+1];
            }
        }
    }
    
    for (int i=1; i<H+1; i++) {
        for (int j=1; j<W+1; j++) {
            if ((S[i])[j] == '#') cout << (S[i])[j];
            else cout << L[i][j];
            
            if (j==W) cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;cin>>s;
  string atcg="ACGT";
  int cnt=0;
  int ans=0;
  for(int i=0;i<s.length();i++){
    bool isATCG=false;
    for(int j=0;j<atcg.length();j++){
      if(s[i]==atcg[j])isATCG=true;
    }
    if(!isATCG){
      cnt=0;
    }else{
      cnt++;
      ans=max(cnt,ans);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let reader = io::stdin();
    let mut line = String::new();
    let _ = io::stdin().read_line(&mut line);
    let numbers: Vec<i64> = 
        reader.lock()       
        .lines().next().unwrap().unwrap()
        .split(' ').map(|s| s.trim())   
        .filter(|s| !s.is_empty())     
        .map(|s| s.parse().unwrap())      
        .collect();                      
    println!("{}", numbers.iter().max().unwrap() - numbers.iter().min().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int n;
    int b[200001];
    long long ans = 0;
    set<int> s;
    cin >> n;
    for(int i=1;i<=n;i++){
        int a;
        cin >> a;
        b[a] = i;
    }
    s.insert(0);
    s.insert(n+1);
    for(int i=1;i<=n;i++){
        int left, right;
        auto itr = s.lower_bound(b[i]);
        right = *itr--;
        left = *itr;
        ans += (long long) (b[i] - left) * (right - b[i]) * i;
        s.insert(b[i]);
    }
    cout << ans << endl;
}


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

int main(){
  int N, A, B;
  cin >> N;
  int A_tokuten = 0;
  int B_tokuten = 0;
  int turn = 1;
  vector<int> vec(N);
  
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  while(vec.size()>0){
    A = 0;
    for(int i=0; i<vec.size(); i++){
      if(A < vec.at(i)){
        A = vec.at(i);
        B = i;
      }
    }
    if(turn%2 == 1){
      A_tokuten += A;
    }
    else{
      B_tokuten += A;
    }
    vec.erase(vec.begin()+B);
    turn += 1;
  }
  cout << A_tokuten - B_tokuten << endl;
}

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

signed main()
{
   int h,w,x,y; cin>>h>>w>>x>>y;
   if(h*w%2==1 and (x+y)%2==1) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
}




Measured memory_bytes: 3088
package main

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

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	// a := make([][]int, 3)
	// for i := 0; i < 3; i++ {
	// 	a[i] = make([]int, 3)
	// }
	// for i := 0; i < 3; i++ {
	// 	for j := 0; j < 3; j++ {
	// 		a[i][j] = nextInt()
	// 	}
	// }

	a := nextLine()
	b := nextLine()

	x, _ := strconv.Atoi(a + b)

	for i := 1; i <= 100100; i++ {
		if i*i == x {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")

}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    fastIO;
    int K;
    cin >> K;
    ll ans = 0;
    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            for (int k = 1; k <= K; ++k) {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

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

using namespace std;

typedef long long ll;

ll n, m;

int main(){
  cin >> n >> m;
  if(m >= 2 * n){
    cout << n + (m - 2 * n) / 4 << endl;
  }
  else{
    cout << m / 2 << endl;
  }
  return 0;
}

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

int main()
{
  char text[1000],such[100];
  int tl,sl;
  int t = 0;
  int p = 0;
  
  scanf("%s", text);
  scanf("%s", such);
  tl = strlen(text);
  sl = strlen(such);

  for(int i = 0; i < tl; i++)
    {
      if(t)
	{
	  break;
	}
      for(int j = 0 ; j < sl; j++)
	{
	  p = i+j;
	  if(p>=tl)
	    {
	      p-=tl;
	    }
	  if(text[p] != such[j])
	    {
	      break;
	    }
	  if(j==sl-1)
	    {
	      t++;
	    }
	}
    }
  if(t)
    {
      printf("Yes\n");
    }
  else
    {
      printf("No\n");
    }
}



Measured memory_bytes: 2140
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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


int main(){
    ll N,M;cin>>N>>M;
    vector<ll> A(N);
    ll sum=0;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        sum+=A[i];
    }
    sort(A.begin(),A.end());
    if(A[N-M]<(double)sum/4/(double)M){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    


}


Measured memory_bytes: 256
#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
k = int(input())

xs = list(range(1, 10))
x_cnt = 0

while x_cnt + len(xs) < k:
    x_cnt += len(xs)
    next_xs = []
    for x in xs:
        ones_place = x % 10
        mul_10 = x * 10
        if ones_place != 0:
            next_xs.append(mul_10 + ones_place - 1)
        next_xs.append(mul_10 + ones_place)
        if ones_place != 9:
            next_xs.append(mul_10 + ones_place + 1)
    xs = next_xs

print(xs[k - x_cnt - 1])


Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+10;
typedef long long ll;

int sum[N << 2];

void pushup(int rt){
	sum[rt] = sum[rt << 1]|sum[rt << 1|1];
	return ;
}

void build(int rt,int l,int r){
	if(l == r){
		char ch;
		cin >> ch;
		sum[rt] = (1 << (ch-'a'));
		return ;
	}
	int m = (l+r) >> 1;
	build(rt << 1,l,m);
	build(rt << 1|1,m+1,r);
	pushup(rt);
	return ;
}

void update(int rt,int pos,int l,int r,int val){
	if(l == r){
		sum[rt] = val;
		return ;
	}
	int m = (l+r) >> 1;
	if(pos <= m) update(rt << 1,pos,l,m,val);
	else update(rt << 1|1,pos,m+1,r,val);
	pushup(rt);
	return ;
}

inline int query(int rt,int L,int R,int l,int r){
	if(L <= l && r <= R) return sum[rt];
	int ans = 0;
	int m = (l+r) >> 1;
	if(L <= m) ans |= query(rt << 1,L,R,l,m);
	if(R > m) ans |= query(rt << 1|1,L,R,m+1,r);
	return ans;
}

inline int cal(int k){
	int ans = 0;
	while(k){
		k -= k&(-k);
		ans++;
	}
	return ans;
} 

int main()
{
	char ch;
	int n,m,op,l,r;
	scanf("%d",&n);
	build(1,1,n);
	scanf("%d",&m);
	while(m--){
		scanf("%d",&op);
		if(op == 1) scanf("%d %c",&l,&ch),update(1,l,1,n,(1 << (ch-'a')));
		else scanf("%d%d",&l,&r),printf("%d\n",cal(query(1,l,r,1,n)));
	}
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef long long int ll;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


ll n, m;
string s, t;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b){
	ll x, y;
	return extgcd(a, b, x, y);
}

int main(void){
	cin >> n >> m;
	cin >> s;
	cin >> t;

	ll g = gcd(n, m);
	for(ll i=0;i<g;i++){
		if (s[n/g*i]!=t[m/g*i]){
			cout << -1 << endl; return 0;
		}
	}
	cout << n * m / g << endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#define re register
#define rep(i,s,t) for(re int i=s;i<=t;++i)
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	if(a+b==15){
		puts("+");
		return 0;
	}
	if(a*b==15){
		puts("*");
		return 0;
	}
	puts("x");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
xi = list(map(int,input().split()))
yi = list(map(int,input().split()))
dxy = [abs(a-b) for (a,b) in zip(xi,yi)]
for p in range(1,4):
    print (sum(map(lambda t: t**p,dxy))**(1/p))
print (max(dxy))



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

using namespace std;

//#define MD 10

int main(){
    int n;
    cin>>n;
    int flag,i,j;
    long int cnt=0;
    
  for( i=2;i<=55555;++i ) {
    flag = 0;
    for( j=2;j<i;++j ){
      if( i%j==0 ) {
        flag = 1;
        break;
      }
    }
    if(flag==0 && i%10==1){
        cout<<i;
        cnt++;
        if(cnt==n){
            cout<<endl;
            return 0;
        }else{
            cout<<" ";
        }
    }
  }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    string s;
    cin >> s;
    int ct = 0;
    bool ok = true;
    if(s.size()%2==1){
        cout << "No" << endl;
        return 0;
    }
    while(ct+2<=s.size()){
        if(!(s[ct]=='h')|| !(s[ct+1]=='i')) {
            ok = false;
            break;
        }
        ct+=2;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> cs(n-1),ss(n-1),fs(n-1);
	rep(i,n-1)cin >> cs[i] >> ss[i] >> fs[i];
	rep(s,n){
		int ret = 0;
		for(int i = s;i < n-1;i++){
			if(ret <= ss[i])ret = ss[i];
			else ret = (ret+fs[i]-1)/fs[i]*fs[i];
			ret += cs[i];
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
bool comp(pair<string, ll> l1, pair<string, ll> l2){
    if(l1.first == l2.first){
        return l1.second > l2.second;
    }
    return l1.first < l2.first;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S[110];
    ll P[110];
    rep(i,0,N) cin >> S[i] >> P[i];
    vector< pair<string, ll> > lp;
    map<pair<string, ll>, ll> mp;
    rep(i,0,N) mp[make_pair(S[i], P[i])] = i;
    rep(i,0,N) lp.push_back(make_pair(S[i], P[i]));
    sort(lp.begin(), lp.end(), comp);
    rep(i,0,N){
        print(mp[lp[i]] + 1);
    }

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	
	vector<char> Hands;

	rep(i, N) {
		char tmp = 'n';

		if(T[i]=='r') tmp = 'p';
		else if(T[i]=='s') tmp = 'r';
		else if(T[i]=='p') tmp = 's';
		
		if(i>=K) {
			if(tmp==Hands[i-K]) tmp = 'n';
		}

		Hands.push_back(tmp);
	}
			
	/* calculate points */ 
	int ans = 0;
	rep(i, N) {
		if(Hands[i]=='r') ans += R;
		else if(Hands[i]=='s') ans += S;
		else if(Hands[i]=='p') ans += P;
//		cout << Hands[i];
	}
	// cout << endl;

	cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
class train{
public:
    int a,b,c,use;
    train():use(0){
        
    }
};
int main(){
    int N,M;
    int *move;
    cin>>N>>M;
    move=new int[M];
    train *city;
    city=new train[N+1];
    int nplace,to;
    cin>>nplace;
    for(int i=1;i<M;++i){
        cin>>to;
        if(nplace<to){
            while(nplace<to){
                ++city[nplace+1].use;
                ++nplace;
            }
        }else{
            while(nplace>to){
                ++city[nplace].use;
                --nplace;
            }
        }
    }
    for(int i=2;i<N+1;++i){
        cin>>city[i].a>>city[i].b>>city[i].c;
    }
    long long ans=0;
    for(int i=2;i<N+1;++i){
        ans+=min((long long)city[i].use*city[i].a,(long long)city[i].use*city[i].b+city[i].c);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4664
import Data.Char
import Data.Bits

printWithSign :: Int -> String
printWithSign x
    | x >= 0 = "+" ++ show x
    | x < 0 = show x

solve :: [Int] -> Int -> [[Int]]
solve xs i = [l | j <- [0..i], let l = loop xs j, sum l == 7]
    where
        loop :: [Int] -> Int -> [Int]
        loop [x] _ = [x]
        loop (x:y:xs) i
            | i .&. 1 == 1 = x : loop (y:xs) (shiftR i 1)
            | otherwise = x : loop (negate y:xs) (shiftR i 1)

main = do
    xs <- map digitToInt <$> getLine :: IO [Int]
    let [a,b,c,d] = head $ solve xs (2^(length xs - 1) - 1)
    putStr $ show a
    putStr $ printWithSign b
    putStr $ printWithSign c
    putStr $ printWithSign d
    putStrLn  "=7"

Measured memory_bytes: 508
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

using namespace std;

// int solve(int a,int b,int c,int x,int y){
//     int ans = 0;
//     if(a>2*c){
//         ans += 2*c*x;
//         y -= x;
//     }else ans += a*x;
//     ans += (b>2*c?2*c*y:b*y);
//     return ans;
// }

int main(void){
    cin.sync_with_stdio(false);
    int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
    int ans = 0;
    cout<<min(
        a*x+b*y,
        min(
            c*2*min(x,y) + (x>y?a:b)*(max(x,y)-min(x,y)),
            c*2*max(x,y)
        )
    )<<endl;
    // if(x==y){
    //     cout<<min(
    //         c*2*x,
    //         a*x+b*y
    //     )<<endl;
    // }else{
    //     if(x>y){
    //         min(
    //             c*2*max(x,y),
    //             a*x+b*y
    //         )
    //     }
    // }
    return 0;
}

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

int main(){
	int h, w;
	string m[51];
	
	cin >> h >> w;
	for(int y=0 ; y < h ; y++ ){
		cin >> m[y];
	}

	int dp[51][51] = {0};
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( x == 0 && y == 0 ) continue;

			if( x == 0 ){
				int c = dp[y-1][x];
				dp[y][x] = c + (m[y][x] - '0');
			}else if( y == 0 ){
				int c = dp[y][x-1];
				dp[y][x] = c + (m[y][x] - '0');
			}else{
				int c = min( dp[y-1][x] , dp[y][x-1] );
				dp[y][x] = c + (m[y][x] - '0');
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
}

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

string s;
int main(){
	ios::sync_with_stdio(false);
	cin>>s;
	int i;
	for(i=0;s[i]!=0;++i)
		if(s[i]=='?')
			s[i]='D';
	cout<<s;
	
	
	return 0;
}

Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }

        static void MainStream()
        {
            //入力を作る
            var sheet = new List<List<char>>();
            string[] h_w = Console.ReadLine().Split();
            int h = int.Parse(h_w[0]);
            int w = int.Parse(h_w[1]);
            int decrease_h = 0;
            for(var i=0;i<h;i++)
            {
                string tmp = Console.ReadLine();
                char[] input = tmp.ToCharArray();
                //１列に片方しか含まれない場合sheetに追加しない
                if(!(input.Contains('#')))
                {
                    decrease_h += 1;
                    continue;
                }
                List<char> line = new List<char>(input);
                sheet.Add(line);
            }
            h -= decrease_h;

             //行を調べる
            for(var j=0;j<w;j++)
            {
                var row = new List<char>();
                for(var i = 0; i<h;i++)
                {
                    row.Add(sheet[i][j]);
                }
                if (!(row.Contains('#')))
                {
                    for(var l=0; l<h; l++)
                    {
                        sheet[l].RemoveAt(j);
                    }
                    w -= 1;
                    j -= 1;
                }
            }
            PrintSheet(sheet);

            


        }
        static void PrintSheet(List<List<char>> sheet)
        {
            foreach(var row in sheet)
            {
                foreach(var rec in row)
                {
                    Console.Write(rec);
                }
                Console.WriteLine("");
            }
        }



    }
}


Measured memory_bytes: 13280
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5+5;
int dp[MAXN];
int dp2[MAXN];
int main() {
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    s = '#'+s;
    for(int i=1;i<=n;i++){
        dp[i] = dp[i-1];
        if(s[i] == 'o'){
            dp[i] =max(dp[i],dp[max(0,i-c-1)]+1);
        }
      //  cout<<dp[i]<<endl;
    }
    for(int i=n;i>=1;i--){
        dp2[i] = dp2[i+1];
        if(s[i] =='o'){
            dp2[i] = max(dp2[i],dp2[min(n+1,i+c+1)]+1);
        }
        //cout<<dp2[i+1]<<endl;
    }
    //int ans = 0;
    for(int i=1;i<=n;i++){
        if(dp[i-1]+dp2[i+1]==(k-1)){
            cout<<i<<endl;
        }
    }
    //cout<<ans<<endl;
}

Measured memory_bytes: 3392
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n, a, b;
    cin >> n;
    
    ll amax, bmin = 2e9;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (bmin > b) {
            amax = a;
            bmin = b;
        }
    }
    
    cout << amax + bmin << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using Graph = vector<vector<int> >;
using Edge = pair<int, int>;

int main() {
    int h,w;
    cin>>h>>w;
    Graph G(h, vector<int>(w));
    queue<Edge>que;
    int cnt=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char a;
            cin>>a;
            if(a=='.'){
                G.at(i).at(j)=-1;
                cnt++;
            }
            else{
                G.at(i).at(j)=0;
                que.push(Edge(i,j));
            }
        }
    }
    vector<int>dx={1,0,0,-1};
    vector<int>dy={0,1,-1,0};
    // cout<<"AAA"<<endl;

    while(!que.empty()){
        int count=0;
        Edge v = que.front();
        que.pop();
        for(int i=0;i<4;i++){
            if(v.first+dx.at(i)>=0 && v.first+dx.at(i)<h && v.second+dy.at(i)>=0 && v.second+dy.at(i)<w){
                if(G.at(v.first+dx.at(i)).at(v.second+dy.at(i)) == -1){
                    G.at(v.first+dx.at(i)).at(v.second+dy.at(i))=G.at(v.first).at(v.second)+1;
                    que.push(Edge(v.first+dx.at(i),v.second+dy.at(i)));
                }
            }
        }
    }

    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,G.at(i).at(j));
        }
    }
    cout<<ans<<endl;







    return 0;
}


Measured memory_bytes: 12432
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(a,b) for(int a=0;a<b;a++)
#define repd(a,b) for(int a=b;a>=0;a--)
signed main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    rep(i,n-2)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
    }
    cout<<ans<<"\n";
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    ll sum=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                sum+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3616
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
//# pragma GCC target ("sse4")
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static char s[1 << 20];
    int k;
    fi>>(s + 1)>>k;
    int n = strlen(s + 1);
    for (int i = 1;i < n;++i)
    {
        int nxt = ('z' + 1 - s[i]) % 26;
        if (k >= nxt) s[i] = 'a',k -= nxt;
    }
    k %= 26;
    while (k --)
        if (s[n] == 'z') s[n] = 'a';
        else s[n]++;
    fo << (s + 1) << '\n';
    return 0;
}

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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)

	

	int32_t main()
	{

	 
	  int k,a,b;
	  cin >> k >> a >> b;
	  if(a%k==0 || b%k==0 || (b/k-a/k)>0) cout<<"OK";
	  else cout<<"NG";

	}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

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


int main(){

    int N;
    string s;
    getline(cin, s);
    N = atoi(s.c_str());

    vector<int> A(N);

    int i = 0;
    while(getline(cin, s, ' ')){
        A[i] = atoi(s.c_str()) - (i + 1);
        i++;
    }

    sort(A.begin(), A.end());

    int b;
    if(N % 2 == 0){
        b = A[N / 2];
    }else{
        b = A[(N - 1) / 2];
    }

    ll sum = 0;
    for(i = 0; i < N; i++){
        sum += abs(A[i] - b);
    }

    cout << sum;

    return 0;
    
}

Measured memory_bytes: 1024
#include<cstdio>
#include<stack>
using namespace std;
static const int MAXN=101;
static const int INF=(1<<21);
int main(){
	int m[MAXN][MAXN],n,u,k,v,i,j,first[MAXN]={},second[MAXN]={},l,c=1,o,z=2;
	stack<int> s;
	bool used[MAXN]={};
	scanf("%d",&n);
	for(i=1;i<n+1;i++){
		for(j=1;j<n+1;j++){
			m[i][j]=INF;
		}
	}
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			m[u][v]=1;
		}
	}
	s.push(1);
	used[1]=true;
	while(1){
		l=s.top();
		if(first[l]==0){
			first[l]=c;
		}
		o=0;
		for(i=1;i<n+1;i++){
			if(m[l][i]==1&&used[i]==false){
				s.push(i);
				o=1;
				used[i]=true;
				break;
			}
		}
		c++;
		if(o==0){
			second[l]=c;
			s.pop();
		}
		if(s.empty()){
			z=0;
			for(i=1;i<n+1;i++){
				if(used[i]==false){
					s.push(i);
					z=1;
					used[i]=true;
					break;
				}
			}
		}
		if(z==0){
			break;
		}
		if(z==1){
			c++;
			z=2;
		}
	}
	for(i=1;i<n+1;i++){
		printf("%d %d %d\n",i,first[i],second[i]);
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

//// Matrix
//// calc with matrix
long long M;
typedef vector<long long> vec;
typedef vector<vec> mat;
struct Matrix{
	int N;
	mat a;
	Matrix(int n){
		N=n;
		a=mat(N,vec(N));
		for(int i=0;i<N;i++)a[i][i]=1;
	}
	Matrix pow(long long b) const {
		Matrix res(N);
		Matrix d(N);
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[i][j]=a[i][j];
		for(;b>0;b>>=1,d=d*d)if(b&1)res=d*res;
		return res;
	}
	Matrix operator+(const Matrix& r) const {
		Matrix s(N);
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				s[i][j]=(a[i][j]+r.a[i][j])%M;
			}
		}
		return s;
	}
	Matrix operator*(const Matrix& r) const {
		Matrix s(N);
		for(int i=0;i<N;i++)s[i][i]=0;
		const long long modl=8*M*M;
		for(int i=0;i<N;i++){
			for(int k=0;k<N;k++){
				for(int j=0;j<N;j++){
					s[i][j]+=a[i][k]*r.a[k][j];
					if(s[i][j]>=modl)s[i][j]-=modl;
				}
			}
			for(int j=0;j<N;j++)s[i][j]%=M;
		}
		return s;
	}

	vector<long long>& operator[](int i){
		return a[i];
	}
};


int n,m,a,b,c,t;
int s[55];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>M>>a>>b>>c>>t;
		if(n==0)break;
		rep(i,n)cin>>s[i];
		Matrix A(n);
		rep(i,n){
			if(i>0)A[i][i-1]=a;
			A[i][i]=b;
			if(i<n-1)A[i][i+1]=c;
		}
		A=A.pow(t);
		//rep(i,n)rep(j,n)dbg(A[i][j]);
		int res[n];
		memset(res,0,sizeof(res));
		rep(i,n)rep(j,n){
			res[i]=(res[i]+s[j]*A[i][j])%M;
		}
		rep(i,n)printf("%d%c", res[i],i==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 3316
#include<stdio.h>

int main(void){
	int n,j=0;
	long long wa=0;
	scanf("%d",&n);
	int a[n+1];
	for(int i=1;i<=n;i++){
		if(i%3==0&&i%5==0) continue;
		else if(i%3==0) continue;
		else if(i%5==0) continue;
		else {
			a[j]=i;
			j++;
		}
	}
	for(int i=0;i<j;i++){
		wa+=a[i];
	}
	printf("%lld\n",wa);
	return 0;
}

Measured memory_bytes: 3816
#include<stdio.h>

int main() {
	long min,max,sum,n,i,a;
	scanf("%ld", &n);
	sum = 0;
	for(i = 0; i < n; i++) {
		scanf("%ld", &a);
		if(i == 0) {
			max = a;
			min = a;
			sum += a;
		}else{
			if(max < a) {
				max = a;
			}
			if(min > a) {
				min = a;
			}
			sum += a;
		}
	}
	printf("%ld %ld %ld\n", min, max, sum);
	
	return 0;
}

Measured memory_bytes: 600
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll inf = ll(1e18) + 1;
const ll mod = pow(10,9)+7;

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

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

	ll result = powMod(10,n,mod);
	result -= powMod(9,n,mod);
	result -= powMod(9, n, mod);
	result += powMod(8, n, mod);

	result %= mod;
	result = (result + mod) % mod;

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>

int main(){


  int a[5];
  int i=0,k;

  while(i < 5){
    scanf("%d",&a[i]);
    i++;
  }
  scanf("%d",&k);

  if(a[4] - a[0] <= k){
    printf("Yay!\n");
  }else{
    printf(":(\n");
  }

  return 0;

}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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



bool isPrime(int x){
    if(x < 2) return false;
    if(x == 2) return true;
    if(!(x % 2)) return false;
    for(int i = 3; i * i <= x; i += 2)
        if(!(x % i)) return false;
    return true;
}

int main(){
    int n, cnt = 0; cin >> n;
    REP(i, n){
        int a; cin >> a;
        if(isPrime(a)) ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}



Measured memory_bytes: 3084
package main

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

func main() {
	A := oneInt()
	B := oneInt()
	C := oneInt()

	if A == B && B == C && C == A || A != B && B != C && C != A {
		fmt.Print("No")
	} else {
		fmt.Print("Yes")
	}

}

func exp(val int) float64 {
	var temp float64
	for index := 1; index <= val; index++ {
		temp += float64(index)
	}
	return temp / float64(val)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


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

int main() {
  ll n,c,k;
  cin >> n >> c >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  ll ans=0;
  ll cnt=0;
  ll i=0;
  ll now=a[0];
  while(i<n){
    ans++;
    i++;
    cnt++;
    while(cnt < c && a[i] <= now+k){
      cnt++;
      i++;
    }
    now = a[i];
    //cout << now << endl;
    cnt = 0;
  }

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

Measured memory_bytes: 4000
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];

    int dp[n]; // dp[i] : minimum const to reach 'i'

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

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

    print(dp[n - 1]);
     
    return 0;
}

Measured memory_bytes: 1024
(let* ((line (read-line nil nil)))
  (if (or (and (char= (char line 0) (char line 1)))
		  (and (char= (char line 1) (char line 2)))
		  (and (char= (char line 2) (char line 3))))
	(format t "Bad")
	(format t "Good")))

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

const int maxn = 1e5 + 10;

const int mod = 998244353;

int a[maxn];

int cnt[maxn];

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
  int n = 0;
  cin >> n;
  for(int i=0;i<n;i++) {
  	cin >> a[i];
  	cnt[a[i]]++;
  }
  
  int ma = *max_element(a, a+n);
  if (a[0] != 0) {
  	cout << 0;
    return 0;
  }
  int res = 1;
  for(int i=1;i<n;i++) {
  	res = 1ll * res * cnt[a[i] - 1] % mod;
  }
  
  cout << res;
  
  
  
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using vpi = vector<pair<int, int>>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n, m; cin >> n >> m;
    F0R (i, m / 2) {
        cout << (1 + i) << " " << (m - i) << nl;
    }
    F0R (i, (m + 1) / 2) {
        cout << (m + 1 + i) << " " << (2 * m + 1 - i) << nl;
    }
    return 0;
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};



int main() {
	IOS();
	ll H, W, h, w;
	cin >> H >> W;
	cin >> h >> w;
	dump((H - h) * (W - w));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,x;
  cin>>a>>b;
  if(b<10){
    x=a*10+b;
  }else if(b<100){
    x=a*100+b;
  }else{
    x=a*1000+b;
  }
  int key=1;
  for(int i=1;i<=1000;i++){
    if(x==i*i){
      cout<<"Yes"<<endl;
      key=-1;
    }
  }
  if(key==1) cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define DIM 500005
using namespace std;
int n, i, x;
int v[DIM];
long long sol;
char s[DIM];
int main(){
    cin>> s + 1;
    n = strlen(s + 1);
    for(i = 1; i <= n; i++){
        if(s[i] == '<'){
            x++;
        }
        else{
            x = 0;
        }
        v[i] = x;
    }
    x = 0;
    for(i = n; i > 0; i--){
        if(s[i] == '>'){
            x++;
        }
        else{
            x = 0;
        }
        v[i - 1] = max(v[i - 1], x);
    }
    for(i = 0; i <= n; i++){
        sol += v[i];
    }
    cout<< sol;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[20];
	int len = 0;
	int i;
	
	scanf("%s", str);
	
	len = strlen(str);
	
	for (i = len - 1; i >= 0; i--){
		printf("%c", str[i]);
	}
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 524
(function main() {
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8'));
  const cache = [1, 1];
  const fib = (n) => cache[n] || (cache[n] = fib(n - 1) + fib(n - 2));
  console.log(fib(n));
})();


Measured memory_bytes: 15384
s[50],j,p,q;
main(i){for(;p=atoi(gets(s));printf("%d\n",i)){
for(i=0;i<p;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=(0x886860>>j++*4)&15;q>1;q-=s[p++]);
}}

Measured memory_bytes: 532
c=0
for W in iter(input,'0'):
 c+=1
 W=int(W)
 d=[0]*-~W
 for _ in[0]*int(input()):
  v,w=map(int,input().split(','))
  for i in range(W,w-1,-1):
   t=d[i-w]+v
   if d[i]<t:d[i]=t
 print(f'Case {c}:\n{d[W]}\n{d.index(d[W])}')


Measured memory_bytes: 5628
#include<stdio.h>
#include<string.h>

int n=0,i,c;
char s[110];

int main(){
	while(scanf("%s",s)!=EOF){
		c=0;
		for(i=0;i<strlen(s)/2;i++){
			if(s[i]==s[strlen(s)-i-1])c++;
		}
		if(c==strlen(s)/2)n++;
	}
	printf("%d\n",n);
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 510000;
const int MOD = 1e9;

const double PI=3.14159265358979323846;

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

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}*/

int length(vector<int> v, int u, int HW){
    if(v.size() == 0) return HW;
    if(v[0] > u) return v[0];
    if(v[v.size() - 1] < u) return HW - v[v.size()- 1] -1;
    else{
        int i = lower_bound(ALL(v), u)- v.begin();
        return v[i] - v[i-1] -1;
    }
}

int main(){
    string str;
    cin >> str;
    list<char> s;
    REP(i, str.size()) s.push_back(str[i]);
    ll Q;
    cin >> Q;
    int parity = 1;
    int t;
    REP(i,Q){
        cin >> t; if(t == 1) parity *= -1;
        else{
            int f; char c; cin >> f >> c; if(f == 2) f = -1;
            if(f * parity == 1) s.push_front(c);
            else s.push_back(c);
        }
    }
    if(parity == 1){
        for(auto itr = s.begin(); itr != s.end(); ++itr) cout << *itr;
    }
    else{
        auto itr = s.end();
        while(itr != s.begin()){
            --itr;
            cout << *itr;
            
        } 
    }
    return 0;
}


Measured memory_bytes: 9984
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
vector<int> G[100050];
int h[100050];
signed main(void)
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		read(h[i]);
	reg int u,v;
	for(int i=1;i<=m;++i)
	{
		read(u);read(v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	reg int ans=0;
	for(int i=1;i<=n;++i)
	{
		reg bool flg=true;
		for(int j=0;j<(int)G[i].size();++j)
		{
			if(h[i]<=h[G[i][j]])
			{
				flg=false;
				break;
			}
		}
		if(flg)
			++ans;
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 9116
dishes = []
5.times do
  dishes.push(gets.to_i)
end
dishes_remainder = []
dishes_actual = []
dish_remainder = 0
dishes.each do |dish|
  dish_remainder = dish % 10
  if dish_remainder == 0
    dishes_actual.push(dish)
    dish_remainder += 10
  else
    dishes_actual.push(dish + (10 - dish_remainder))
  end
  dishes_remainder.push(dish_remainder)
end
shortcut = 10 - dishes_remainder.min
dishes_actual_sum = 0
dishes_actual.each do |disha|
  dishes_actual_sum += disha
end
sum = dishes_actual_sum - shortcut
puts sum

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
#define all(a) a.begin(), a.end()
#define All(a) a.rbegin(), a.rend()
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed
int main()
{
   ios;
   int n, a;
   cin >> n >> a;
   cout << (n * n) - a << '\n';
   return 0;
}

Measured memory_bytes: 3652