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

using namespace std;

const int inf = 1<<29;
const int maxn = 20;

int n;
int dis[maxn+3][maxn+3] = {};
int dp[(1<<maxn)+3][maxn+11] = {};

int solve(int s, int last){
    if (dp[s][last] == 0){
        dp[s][last] = inf;

        if (__builtin_popcount(s) == 1) dp[s][last] = dis[0][last];
        else{
            for(int i = 1;i < n;i++){
                if (i == last) continue;
                if (((1<<i)&s) == 0) continue;
                dp[s][last] = min(dp[s][last], solve(s^(1<<last), i)+dis[i][last]);
            }
        }
    }
    return dp[s][last];
}

int main(){

    cin>>n;
    int e;cin>>e;

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            dis[i][j] = inf;
        }
    }

    while(e--){
        int a, b, d;cin>>a>>b>>d;
        dis[a][b] = d;
    }

    int ans = solve((1<<n)-1, 0);
    if (ans == inf) ans = -1;
    cout << ans << endl;

    return 0;
}

/* input
    5
    0 1 1 1 1
    1 0 1 1 1
    1 1 0 1 1
    1 1 1 0 1
    1 1 1 1 0
*/



Measured memory_bytes: 7068
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

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

    int n;
    long long sum=1;
    cin>>n;

    for(int i=n;i>0;i--){
	sum=(sum*i)%1000000007;
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1;











    getchar();
    getchar();
    return 0;
    //ios::sync_with_stdio(false);
    //cin.tie(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    vector<P> ki(100001);
    vector<P> gu(100001);
    rep(i,100001){
        ki[i].second=i;
        gu[i].second=i;
    }
    int ki_co=0;
    int gu_co=0;
    for(int i=0; i<n; i+=2){
        ki[v[i]].first-=1;
        ki_co++;
    }
    for(int i=1; i<n; i+=2){
        gu[v[i]].first-=1;
        gu_co++;
    }
    sort(ki.begin(),ki.end());
    sort(gu.begin(),gu.end());
    if(ki[0].first==gu[0].first && ki[0].second==gu[0].second){
        if(ki[1].first<=gu[1].first){
            cout<<ki_co+ki[1].first+gu_co+gu[0].first<<endl;
        }
        else{
            cout<<ki_co+ki[0].first+gu_co+gu[1].first<<endl;
        }
    }
    else if(ki[0].first!=gu[0].first && ki[0].second==gu[0].second){
        if(ki[0].first<gu[0].first){
             cout<<ki_co+ki[0].first+gu_co+gu[1].first<<endl;
        }
        else{
            cout<<ki_co+ki[1].first+gu_co+gu[0].first<<endl;
        }
    }
    else{
        cout<<ki_co+ki[0].first+gu_co+gu[0].first<<endl;
    }

}


Measured memory_bytes: 2176
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef pair<long long int, int> P;

int main(){
	
	long long int N, H;
	cin >> N >> H;
	
	vector<P> v;
	
	for(int i = 0; i < N; i++){
		long long int a, b;
		cin >> a >> b;
		P p;
		p.first = -a;
		p.second = 1;
		v.push_back(p);
		p.first = -b;
		p.second = 2;
		v.push_back(p);
	}
	
	sort(v.begin(), v.end());
	
	long long int ans = 0;
	
	for(int i = 0; i < N * 2; i++){
		P p = v[i];
		if(p.second == 2){
			H += p.first;
			ans++;
			if(H <= 0){
				break;
			}
		}else{
			ans += H / -p.first + (H % -p.first != 0);
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

template<class T>
inline void read(T& x) {
  T s = 0, base = 1;
  char c;
  while (!isdigit(c=getchar())) if (c == '-') base = -base;
  while (isdigit(c)) {
    s = s * 10 + (c^48);
    c = getchar();
  }
  x = base * s;
}

int N;
int a;

int main() {
  read(N);
  ll ans = 0;
  REP(i,N) {
    read(a);
    ans += a - 1;
  }
  
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u==s) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
    return 0;
}

Measured memory_bytes: 380
import math
n  =int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
ans = 0
i=0
ind = 0
while (i<n):
    if n-i == 1:
        ans+=a[ind]
        i+=1
    else:
        ans+=2*a[ind]
        i+=2
    ind+=1
    # print(ans,i)
ans-=a[0]
print(ans) 

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

int main() {
	long long n;
	scanf("%lld",&n);
	if(n<2)printf("0");
	else if(n%2==1)printf("0");
	else{
		long long div=1;
		long long ans=0;
		for(int i=1;i<=26;i++){
			div*=5LL;
			if(div*2>n)break;
			ans+=n/div/2;
			//printf("%lld %lld\n",div,ans);
		}
		printf("%lld",ans);
	}
}


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

int main(){
  int64_t n;
  cin >> n;
  int64_t a=100,c=0;
//  const long double x=1.01;
  while(a<n){
    c++;
    a+=a/100;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3680
'''
Date         : 2020-08-10 14:56:09
Author       : ssyze
Description  : 
'''
n = int(input())
ac = 0
tle = 0
wa = 0
re = 0
for i in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'TLE':
        tle += 1
    elif s == 'WA':
        wa += 1
    else:
        re += 1
print("AC x %d" % ac)
print("WA x %d" % wa)
print("TLE x %d" % tle)
print("RE x %d" % re)


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

int main(void){
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(U==S){
        cout << A-1 << " " << B << endl;
    }
    else{
        cout << A << " " << B-1 << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
    String s=buf.readLine();
    String[] x=s.split(" ");
    int a=Integer.parseInt(x[0]);
    int b=Integer.parseInt(x[1]);
    int c=Integer.parseInt(x[2]);
    
    if(a<b && b<c)
        System.out.println("Yes");
     else
        System.out.println("No");
    }
}

Measured memory_bytes: 24088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;


int main(){
  string s;
  cin>>s;
  int N=s.size();
  int n=N/2;
  int m;cin>>m;
  vector<int> v[n];
  int a[m],b[m];
  rep(i,m)cin>>a[i]>>b[i];
  if(N%2){
      rep(i,m)if(a[i]>n+1)a[i]--;
      rep(i,m)if(b[i]>n)b[i]--;
  }
  rep(i,m){
      if(b[i]<=n)a[i]--,b[i]--;
      else if(a[i]>n)a[i]=2*n-a[i],b[i]=2*n-b[i],swap(a[i],b[i]);
      else{
          a[i]--;
          b[i]=2*n-b[i];
          if(a[i]>b[i])swap(a[i],b[i]);
           b[i]--;
      }
      if(a[i]<=b[i])v[a[i]].push_back(b[i]);
  }
  vector<int> mi(n,-1);
  rep(i,n){
      if(v[i].empty())continue;
      sort(v[i].begin(),v[i].end());
      mi[i]=v[i][0];
      REP(j,1,v[i].size()){
          if(v[i][j-1]!=v[i][j])v[v[i][j-1]+1].push_back(v[i][j]);
      }
  }
  int c[n];
  rep(i,n)c[i]=s[i]-s[N-1-i];
  rep(i,n-1)c[n-i-1]-=c[n-i-2];
  rep(i,n){
      if(mi[i]==-1){
          if(c[i]%26==0)continue;
          else {
              cout<<"NO"<<endl;
              return 0;
          }
      }
      c[mi[i]+1]+=c[i];
    }
   cout<<"YES"<<endl; 
  return 0;
  }


Measured memory_bytes: 7296
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

using namespace std;

typedef long long Int;
const Int mod = 1000000007;
const Int INF = mod * mod;

int main() {
	Int w, h, x, y;
	cin >> w >> h >> x >> y;
	if (w == 2 * x && h == 2 * y) {
		cout << w * h / 2.0 << ' ' << 1 << endl;
	}
	else {
		cout << w * h / 2.0 << ' ' << 0 << endl;
	}
}

Measured memory_bytes: 256
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    q = int(input())

    add_head = []
    add_tail = []
    is_reversed = False

    for _ in range(q):
        q = list(map(str,input().split()))
        if q[0] == "1":
            if is_reversed:
                is_reversed = False
            else:
                is_reversed = True
        else:
            if q[1] == "1":
                if is_reversed:
                    add_tail.append(q[2])
                else:
                    add_head.append(q[2])
            else:
                if is_reversed:
                    add_head.append(q[2])
                else:
                    add_tail.append(q[2])

    ans = []

    if is_reversed:
        add_head.reverse()
        ans += add_head
        ans += s
        ans += add_tail
        ans.reverse()
    else:
        add_head.reverse()
        ans += add_head
        ans += s
        ans += add_tail

    print(''.join(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 73152
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


bool f(int num)
{
	if (num == 0 || num == 1) return false;
	for (int i = 2; i*i < num + 1; i++) {
		if (num % i == 0) return false;
	}
	return true;
}

int main()
{
	while (1) {
		ll a, d, n;
		cin >> a >> d >> n;
		if (a == 0 && d == 0 && n == 0) {
			return 0;
		} else {
			cnt = 0;
			while (true) {
				if (f(a)) cnt++;
				if (cnt == n) break;
				a += d;
			}
			cout << a << endl;
		}
	}
}

Measured memory_bytes: 3132
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            var answer = 0;
            for (var i = 1; i < S.Length; i++)
            {
                if (S[i] != S[i - 1]) answer++;
            }
            Console.WriteLine(answer);
        }
    }
}


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

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    for(int i = 0;i < h;i ++){
        vector<int> v(0);
        for(int j=0;j < w;j ++){
            v.push_back(a.back().second);
            a.back().first --;
            if(!a.back().first) a.pop_back();
        }
        if(i%2) reverse(v.begin(),v.end());
        for(int j = 0;j < w;j ++){
            cout << v[j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N = int(input())
S = list(map(int, list(input())))

cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            pin = [i, j, k]
            x = 0

            for a in S:
                if a == pin[x]:
                    x += 1
                    if x == 3:
                        cnt += 1
                        break

print(cnt)

Measured memory_bytes: 43088
#include <stdio.h>
typedef struct{
	int g,t,p;
}gtp;
int main(void){
	int n,i,j;
	int A[10];
	char str[10];
	gtp cnt;

	while(1){
		cnt.g=0; cnt.t=0; cnt.p=0;
		for(i=0;i<5;i++){
			fgets(str,sizeof(str),stdin);
			sscanf(str,"%d",&n);
			switch(n){
				case 0: return 0;
				case 1: cnt.g+=1; break;
				case 2: cnt.t+=1; break;
				case 3: cnt.p+=1; break;
			}
			A[i]=n;
		}
			if((cnt.g!=0 && cnt.t!=0 && cnt.p!=0) || (cnt.g==0 && cnt.t==0)
					|| (cnt.t==0 && cnt.p==0) || (cnt.p==0 && cnt.g==0)){
				for(j=0;j<5;j++)
					A[j]=3;
			}
			else if(cnt.g==0){
				for(j=0;j<5;j++){
					switch(A[j]){
						case 2: A[j]=1; break;
						case 3: A[j]=2; break;
					}
				}
			}
			else if(cnt.t==0){
				for(j=0;j<5;j++){
					switch(A[j]){
						case 3: A[j]=1; break;
						case 1: A[j]=2; break;
					}
				}
			}
			else if(cnt.p==0){
				for(j=0;j<5;j++){
					switch(A[j]){
						case 1: A[j]=1; break;
						case 2: A[j]=2; break;
					}
				}
			}
			for(j=0;j<5;j++)
				printf("%d\n",A[j]);

	}
	return 0;
}			

Measured memory_bytes: 612
using System;
 
public class p0003{
    p0003(){
        int n;
        string str;
        string[] s;
        int[] a = new int[3];
         
        while((str = Console.ReadLine()) != null){
            n = int.Parse(str);
             
            while(0 < n--){
                s = (Console.ReadLine()).Split(' ');
                for(int i = 0; i < 3; ++i){
                    a[i] = int.Parse(s[i]);
                    a[i] = a[i]*a[i];
                }
                Console.WriteLine("{0}", ((func(a))? "YES": "NO"));
            }
        }
    }
     
    public static int Main(string[] args){
        new p0003();
        return 0;
    }
     
    public bool func(int[] a){
        return (a[0] == a[1]+a[2] || a[1] == a[0]+a[2] || a[2] == a[0]+a[1]);
    }
}

Measured memory_bytes: 5436
n,*a=map(int,open(0).read().split())

# mx=n*(n-1)//2
# n <=2*10**5
from collections import Counter
b=[]
c=[]
for i,q in enumerate(a):
    b.append(i+q)
    c.append(i-q)
# print(b,c)
bb=Counter(b).items()
cc=Counter(c)

# print(bb,cc)
ans=0
for (bi,bj) in bb:
    ans+=bj*cc[bi]
print(ans)

Measured memory_bytes: 146660
#include<iostream>
using namespace std;
int n, m;
int ans;
int main() {
	cin >> n >> m;
	if(!n and !m)
		ans = 0;
	else if(n and !m)
		ans = (n - 1) * n / 2;
	else if(!n and m)
		ans = (m - 1) * m / 2;
	else
		ans = ((n - 1) * n + (m - 1) * m) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define M(x) ((x) % MOD)
#define N 100001
using namespace std;

typedef unsigned ui;
typedef long long ll;
typedef unsigned long long ul;

ul f[N];

int main(void) {
	ios::sync_with_stdio(0); cin.tie(0);
#ifdef _DEBUG
	ifstream cin("1.in");
#endif
	for (ui i = f[0] = 1; i != N; ++i)
		f[i] = M(f[i - 1] * i);
	ll n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) cout << 0 << endl;
	else {
		if (n == m) cout << M(2 * f[n] * f[n]) << endl;
		else cout << M(f[n] * f[m]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

/*

?????°
???????????????2????????´??° a ??¨ b ??????????????°???????????????????????°?????????????????????????????????

Input
?????°????????????????????????????????????????????????????????????????????? 1 ???????????????????????????????????????????????????2????????´??° a ??¨ b ???1????????????????????§??????????????????????????????????????\????????????????????§????????????????????????

Constraints
0 ? a, b ? 1,000,000
???????????????????????° ? 200
Output
??????????????????????????¨??????a+b ????????°???????????????????????????

*/

int digitNumber( int num )
{
	if ( num < 10 ) {
		return 1;
	}
	else if ( num < 100 ) {
		return 2;
	}
	else if ( num < 1000 ) {
		return 3;
	}
	else if ( num < 10000 ) {
		return 4;
	}
	else if ( num < 100000 ) {
		return 5;
	}
	else if ( num < 1000000 ) {
		return 6;
	}
	else {
		return 7;
	}
}

int main( void )
{
	int a, b;
	
	while(scanf("%d %d", &a, &b) != EOF) {
	
		printf( "%d\n", digitNumber( a + b ) );
	}
	
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n ; j++){
            if(s[i] == s[j]){
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}



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

int main(){

	long long int n;
	cin >> n;

	if(n%2==1)
	{
		cout << 0 << endl;
		return 0;
	}
	
	long long int ans=0;
	long long int num=1;
	
	for(int i=1;i<26;i++)
	{
		num=1;
		for(int j=1; j<=i; j++)
		{
			num*=5;
		}
		ans+=(n/num)/2;
	}
	
	cout << ans;
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a>b){
		for(int i=1;i<=a;i++){
			cout << b;
		}
		cout << endl;
	}
	else{
		for(int i=1;i<=b;i++){
			cout << a;
		}
		cout << endl;
	}
	return 0;
} 

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

#define _USE_MATH_DEFINES
#include <math.h>

// cl /EHsc xxxx.c
int main(int arc, char *argv[])
{
	int a, b;
	char op;
	
	while (1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?')
		{
			break;
		}
		
		switch (op)
		{
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		default:
			break;
		}
	}
	
	return 0;
}

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

N = int(input())
h = list(map(int, input().split()))
#print(N)
#print(h)

dp = ['' for i in range(N)]
#print(dp)

#dp[0]を代入
dp[0] = h[0]

#初期値
ans = "Yes"

for i in range(1,N):
    if h[i] == dp[i-1]: #h[i] == dp[i-1]
        dp[i] = dp[i-1]

    elif h[i] > dp[i-1]:#h[i] > dp[i-1]
        if h[i]-1 == dp[i-1]: #1しか差がないなら
            dp[i] = dp[i-1]
        else:
            dp[i] = h[i]-1
    else:#h[i] < dp[i-1]
        ans = "No"
        break

#print(dp)
print(ans)



Measured memory_bytes: 14704
#include<iostream>
#include<algorithm>
using namespace std;
int a[300000]={0};
int main()
{
	int n,m,i;
	cin>>n>>m;
	for(i=0;i<m;i++)
	cin>>a[i];
	int ans=2*n;
	
	for(i=0;i<m;i++)
	{
		if(i==0)
		{
			int l=a[m-1]-a[i];
			if(l<ans) ans=l;
		}
		else
		{
			int l=n+a[i-1]-a[i];
			if(l<ans) ans=l;
		}
	}
	cout<<ans<<endl;
 } 

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

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

  LL ans;
  if (k % 2 == 0) {
    ans = a - b;
  } else {
    ans = b - a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
curves = [[0.0,0.0], [100.0,0.0]]
gets.to_i.times do
    next_curves = []
    curves.map.with_index do |point, index|
        if point[0] == 100.0 && point[1] == 0.0
            next_curves.push(point)
        else
            point_next = curves[index+1]

            next_curves.push(point)

            x = (point[0]*2+point_next[0])/3.0
            y = (point[1]*2+point_next[1])/3.0
            next_curves.push([x,y])

            diff_x = x - point[0]
            diff_y = y - point[1]
            x = diff_x/2 - diff_y*(3**0.5)/2 + x
            y = diff_x*(3**0.5)/2 + diff_y/2 + y
            next_curves.push([x,y])

            x = (point[0]+point_next[0]*2)/3.0
            y = (point[1]+point_next[1]*2)/3.0
            next_curves.push([x,y])
        end
    end
    curves = next_curves
end

curves.each do |point|
    puts "#{format("%.5f", point[0])} #{format("%.5f", point[1])}"
end


Measured memory_bytes: 7008
x, k, d = map(int, input().split())

x = abs(x)

n = x // d
q = x % d
p = q - d

if n < k:
    l = k - n

    if l % 2 == 0:
        print(q)

    else:
        print(abs(p))

else:
    e = x - k * d
    print(e)


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> c(20, vector<int>(20));
    vector<pair<int, int>> a;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ll x = 0;
        bool found = false;
        for (int i = 0; i < (int)s.size(); i++) {
            if (s[i] != '.') (x *= 10) += s[i] - '0';
            else found = true;
        }
        if (!found)  x *= (ll)1e9;
        else {
            int cur = 0;
            while (s.back() != '.')
                ++cur,s.pop_back();
            for (int it = 0; it < 9 - cur; it++) x *= 10;
        }
        int c2=0,c5=0;
        ll y = x;
        while (y % 2 == 0)
            ++c2,y /= 2;
        y = x;
        while (y % 5 == 0)
            ++c5,y /= 5;
        ++c[min(18, c2)][min(18, c5)];
        a.emplace_back(min(18, c2), min(18, c5));
    }
    for (int i = 18; i >= 0; i--)
        for (int j = 18; j >= 0; j--)
            c[i][j] += c[i + 1][j] + c[i][j + 1] - c[i + 1][j + 1];
    ll w = 0;
    for (auto x : a)
        w += c[18 - x.first][18 - x.second] - (x.first >= 9 && x.second >= 9);
    w /= 2;
    cout << w;
    return 0;
}

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

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

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    
    string s;
    cin >> s;
    ll w;
    cin >> w;

    ll i = 0;
    ll n = s.size();
    string o = "";
    while(i < n){
        o += s[i];
        i += w;
    }

    cout << o << endl;

    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long int

int main(){
  ll n;
  scanf("%lld",&n);
  char s[4001];
  scanf("%s",s);

  ll ans=0;
  ll dec=0;

  for(int inte=1;inte<=n/2;inte++){
    for(int fir=0;fir+2*inte<n;fir++){
      int sec=fir+inte;
      int thi=sec+inte;
	if(s[fir]==s[sec] || s[sec]==s[thi] || s[thi]==s[fir]){
	  continue;}
	//printf("%d %d %d\n",i,j,k);
	dec++;
      }}
  ll r=0;
  ll b=0;
  ll g=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') r++;
    else if(s[i]=='B') b++;
    else if(s[i]=='G') g++;
  }
  ans = r*b*g-dec;

  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,A,B,N,M,K,X,Y,Z;
  string S,T,U;
  cin >> S;

  int length = S.length();

  for(int i=0 ; i < length ; i++){
    cout << "x";
  }
  cout << endl;
}

Measured memory_bytes: 256
N,Y=map(int,input().split())

for x in range(N+1):
    for y in range(N+1):
        z=N-x-y
        if 9*x+4*y==Y*(10**(-3))-N and z>=0:
            print(x,y,z)
            exit()

print("-1 -1 -1")


Measured memory_bytes: 2940
n = int(input())
factor = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
factor_num = [0] * len(factor)
if n <= 9:
	print(0)
else:
	for i in range(2, n+1):
		for j in range(len(factor)):
			cnt = 0
			while i % factor[j] == 0:
				cnt += 1
				i = i // factor[j]
			factor_num[j] += cnt

	#print(factor_num)

	two_three = 0
	over_four = 0
	over_fourteen = 0
	over_twentyfour = 0
	over_seventyfour = 0

	for i in range(len(factor)):
		if 2 <= factor_num[i] <= 3:
			two_three += 1
		elif factor_num[i] >= 4:
			over_four += 1
			if factor_num[i] >= 14:
				over_fourteen += 1
			if factor_num[i] >= 24:
				over_twentyfour += 1
			if factor_num[i] >= 74:
				over_seventyfour += 1

	#print(two_three, over_four, over_fourteen, over_twentyfour, over_seventyfour)

	ans = two_three * (over_four * (over_four - 1) // 2) + over_four * ((over_four - 1) * (over_four - 2) // 2)
	ans += over_fourteen * (over_four - 1) + over_twentyfour * (two_three + over_four - 1)
	ans += over_seventyfour

	print(ans)

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

int main(){
	int n;cin>>n;
	int a,b,c;
	int dp[n][3];
	cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
	for(int i=1;i<n;i++){
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;		
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<3;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
}

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

int main()
{
    int n, i, sum=0;
    cin>>n;
    int arr[n];

    for(i=0; i<n; i++){
        cin>>arr[i];
    }
    sort(arr, arr+n);

    for(i=0; i<n-1; i++){
        sum = sum + arr[i];
    }

    if(arr[n-1] < sum)
        cout<<"Yes";
    else
        cout<<"No";

}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int n,k; cin >> n >> k;
    int a[n]; rep(i,0,n) cin >> a[i];

    rep(i,k,n){
        if(a[i] > a[i-k]){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    map<int, int> sequence;
    int tmp;
    rep(i, n)
    {
        cin >> tmp;
        sequence[tmp]++;
    }
    int cnt = 0;
    for (auto itr = sequence.begin(); itr != sequence.end(); itr++)
    {
        if (itr->first < itr->second)
        {
            cnt += itr->second - itr->first;
        }
        else if (itr->first > itr->second)
        {
            cnt += itr->second;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  ll a,b,m;
  cin >> a >> b >> m;
  vector<ll> aa(a);
  vector<ll> bb(b);
  ll x,y,c;
  for (int i = 0; i < a; i++) cin >> aa[i];
  for (int i = 0; i < b; i++) cin >> bb[i];
  int minv = INT_MAX;
  for(int i = 0; i < (int)aa.size(); ++i) {
    if( aa[i] < minv )
      minv = aa[i];
  }
  int minvv = INT_MAX;
  for(int i = 0; i < (int)bb.size(); ++i) {
    if( bb[i] < minvv )
      minvv = bb[i];
  }
  ll ans = minv+minvv;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> c;
    if (ans > aa[x-1]+bb[y-1]-c) {
      ans = aa[x-1]+bb[y-1]-c;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  char d[60][60];
  
  for(int i = 0;i < 60;i++){
    for(int j = 0;j < 60;j++){
      d[i][j] = '.';
    }
  }

  
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
      cin >> d[i][j];
    }
  }

  
  int no = 0;
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
      if(d[i][j] == '#' &&
         d[i][j+1] == '.' &&
         d[i][j-1] == '.' &&
         d[i-1][j] == '.' &&
         d[i+1][j] == '.' ){
        no++;
        
      }
 
    }
  }
  
  
  if(no > 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{ int a,b;
  cin >> a >> b;
  if (a>b){
    cout << "a > b"<< endl;}
  else if (a<b){
    cout << "a < b" << endl;
  }
    else{
        cout << "a == b" << endl;
    } return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>
int main(){
	int i,temp=0,t1=0,t2=0;
	for(i=0;i<4;i++){
		scanf("%d",&temp);
		t1+=temp;
	}
	for(i=0;i<4;i++){
		scanf("%d",&temp);
		t2+=temp;
	}
	if(t1>t2){
		printf("%d\n",t1);
	}
	else{
		printf("%d\n",t2);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;

#define SIZE 500
#define INF 1000000000

int a[SIZE];
int r[SIZE], b[SIZE];

int sumA, sumR, sumB;

int dp[121][61][50*60+1];

int main() {
  int N, K;

  scanf("%d%d", &N, &K);

  for(int i=0; i<N; i++) {
    scanf("%d", a+i);
    sumA += a[i];
  }

  for(int i=0; i<K; i++) {
    scanf("%d", r+i);
    sumR += r[i];
  }

  for(int i=0; i<K; i++) {
    scanf("%d", b+i);
    sumB += b[i];
  }

  for(int i=0; i<=N; i++) {
    for(int j=0; j<=K; j++) {
      for(int k=0; k<=sumR; k++) {
        dp[i][j][k] = INF;
      }
    }
  }

  sort(a, a+N, greater<int>());
  sort(b, b+K, greater<int>());
  sort(r, r+K, greater<int>());

  dp[0][0][0] = 0;

  for(int i=0; i<N; i++) {
    for(int j=0; j<=K; j++) {
      for(int k=0; k<sumR; k++) {

        if(j < K && k + a[i] <= sumR) {
          dp[i+1][j+1][k+a[i]] = min( dp[i+1][j+1][k+a[i]], dp[i][j][k] + max(a[i] - r[j], 0));
        }

        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k] + max(0, a[i] - b[i-j]));
      }
    }
  }

  int ans = INF;

  for(int j=0; j<=K; j++) {
    for(int k=0; k<=sumR; k++) {
      if(N - j <= K && sumA - k <= sumB)
        ans = min(ans, dp[N][j][k]);
    }
  }

  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}



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

#define fastio 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

string s; int n;

const int N = 1e6 + 5;
long long cc[N][2];

long long dp(int idx, int carry){
  if(idx == n)
    return carry;
  long long &ans = cc[idx][carry];
  if(~ans)
    return ans;
  ans = INF;
  ans = min(ans, 10 - (s[idx] - '0') - carry + dp(idx + 1, 1));
  ans = min(ans, (s[idx] - '0') + carry + dp(idx + 1, 0));
  return ans;
}

void solve(){
  cin >> s;
  n = s.size();
  reverse(all(s));
  memset(cc, -1, sizeof cc);
  cout << dp(0, 0) << '\n';
}

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

  pre();

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

  ktj();
}


Measured memory_bytes: 63900
N = int(input())
H = list(map(int, input().split()))

count = 0
max_count = 0
pre_height = 0

for i in range(len(H)):
	if i == 0:
		pre_height = H[i]
	else:
		if H[i] <= pre_height:
			count += 1
			if max_count < count:
				max_count = count
		else:
			count = 0
		pre_height = H[i]

# print(N, H)
print(max_count)


Measured memory_bytes: 14252
N=int(input())
S=input()
count=0

if N%2==1:
  print("No")
else:
  for i in range(N//2):
    if S[i]==S[i+N//2]:
      count=count+1
    else:
      print("No")
      break
  if count==N//2:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    set<int> st;
    rep(i,n){
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << st.size() << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end() 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    ll x;cin>>x;
    ll k=x%100;
    ll cnt=0;
    cnt+=k/5;
    if(k%5)cnt++;
    if(cnt*100<=x)cout<<1<<endl;
    else cout<<0<<endl;
}

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    const int size = s.size();

    int cnt_swap = 0;
    for (int i = 0; i < size; ++i) {
        if ((i & 1) && s[i] == '0') ++cnt_swap;
        else if (!(i & 1) && s[i] == '1') ++cnt_swap;
    }

    int min_swap = cnt_swap;
    cnt_swap = 0;
    for (int i = 0; i < size; ++i) {
        if ((i & 1) && s[i] == '1') ++cnt_swap;
        else if (!(i & 1) && s[i] == '0') ++cnt_swap;
    }

    min_swap = min(min_swap, cnt_swap);
    cout << min_swap << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct T{
	ll y,a,b;
	bool operator<(const T&q)const{
		return y<q.y;
	}
};
ll n,m,par[100005],w[100005],k[100005],ans;
T e[100005];
ll find(ll x){
	if(par[x]==x)return x;
	ll y=find(par[x]);
	w[y]+=w[x];
	k[y]+=k[x];
	w[x]=0;
	k[x]=0;
	par[x]=y;
	return y;
}
int main(void){
	scanf("%lld%lld",&n,&m);
	for(int i=0;i<n;i++)scanf("%lld",w+i);
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld",&e[i].a,&e[i].b,&e[i].y);
		e[i].a--,e[i].b--;
	}
	sort(e,e+m);
	for(int i=0;i<n;i++)par[i]=i;
	for(int i=0;i<m;i++){
		ll a=e[i].a,b=e[i].b,y=e[i].y;
		a=find(a);
		b=find(b);
		if(a==b){
			if(w[a]>=y)ans++;
			else k[a]++;
		}else{
			w[a]+=w[b];
			k[a]+=k[b]+1;
			w[b]=0;
			k[b]=0;
			par[b]=a;
			if(w[a]>=y){
				ans+=k[a];
				k[a]=0;
			}
		}
	}
	printf("%lld\n",m-ans);
}


Measured memory_bytes: 4992
h, w = map(int, input().split())
S = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == '#':
            continue
        cnt = 0
        for dx in [-1, 0, 1]:
            for dy in [-1, 0, 1]:
                if not 0 <= i+dy <h  or not 0 <= j+dx < w:
                    continue
                if S[i+dy][j+dx] == '#':
                    cnt += 1
        S[i][j] = str(cnt)
for s in S:
    print("".join(s))

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

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

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

  return false;
}

const ll INF = 1LL << 60;
ll dp[100100];

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++) {
    cin >> h[i];
  }
  for(int i = 0; i < N; i++) {
    dp[i] = INF;
  }

  dp[0] = 0;

  for(int i = 0; i < N - 1; i++) {
    chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));

    chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }

  cout << dp[N - 1];
  return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
#include <set>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

struct UnionFind {
  std::vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x])
        std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  // Input
  int N, M;
  std::cin >> N >> M;

  std::vector<int> X(M);
  std::vector<int> Y(M);
  std::vector<int> Z(M);
  for (int i = 0; i < M; ++i)
    std::cin >> X[i] >> Y[i] >> Z[i];

  // Main
  UnionFind uf(N);
  for (int i = 0; i < M; ++i)
    uf.unionSet(X[i] - 1, Y[i] - 1);

  // Output
  std::set<int> s;
  // for (int i = 0; i < M; ++i)
  //   s.insert(uf.root(i));
  for (int j = 0; j < N; ++j)
    s.insert(uf.root(j));

  std::cout << s.size() << std::endl;

  return 0;
}


Measured memory_bytes: 6400
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
int main() {
  string s;
  cin >> s;
  vector<string> a(4);
  bool yes = 1;
  a[0] = "dream";
  a[1] = "dreamer";
  a[2] = "erase";
  a[3] = "eraser";
  rep(i, 0, a.size()) {
    reverse(all(a[i]));
    cerr << a[i] << endl;
  }
  reverse(all(s));
  cerr << s << endl;
  int i = 0;
  while (i < s.length()) {
    bool all = true;
    cerr << i << endl;
    rep(j, 0, a.size()) {
      string sub = s.substr(i, a[j].length());
      cerr << j << "," << sub << endl;
      if (sub.compare(a[j]) == 0) {
        i += a[j].length();
        all = false;
        break;
      }
    }
    if (all) {
      yes = 0;
      break;
    }
  }
  YES(yes);

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  int h,n;
  cin>>h>>n;
  int a = 0;
  rep(i,n){
    int b;cin>>b;
    a += b;
  }
  if(h <= a)cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
program main
  
  implicit none
  integer(4) :: n, i, j
  integer(8) :: nr, ng, nb
  integer(8) :: ans
  character(4000) :: s
  
  read(*,*) n
  read(*,*) s
  
  nr = 0
  ng = 0
  nb = 0
  do i = 1, n
    if( s(i:i) == "R" ) then
      nr = nr + 1
    else if( s(i:i) == "G" ) then
      ng = ng + 1
    else
      nb = nb + 1
    end if
  end do
  ans = nr * ng * nb
  do i = 1, n-2
    do j = i+1, n-1
    if( 2*j-i > n ) cycle
    if( s(i:i) == "R" ) then
      if( s(j:j) == "G" ) then
        if( s(2*j-i:2*j-i) == "B"  ) ans = ans - 1
      end if
    end if
    if( s(i:i) == "R" ) then
      if( s(j:j) == "B" ) then
        if( s(2*j-i:2*j-i) == "G" ) ans = ans - 1
      end if
    end if
    if( s(i:i) == "G" ) then
      if( s(j:j) == "R" ) then
        if( s(2*j-i:2*j-i) == "B" ) ans = ans - 1
      end if
    end if
    if( s(i:i) == "G" ) then
      if( s(j:j) == "B" ) then
        if( s(2*j-i:2*j-i) == "R" ) ans = ans - 1
      end if
    end if
    if( s(i:i) == "B" ) then
      if( s(j:j) == "R" ) then
        if( s(2*j-i:2*j-i) == "G" ) ans = ans - 1
      end if
    end if
    if( s(i:i) == "B" ) then
      if( s(j:j) == "G" ) then
        if( s(2*j-i:2*j-i) == "R" ) ans = ans - 1
      end if
    end if
    end do
  end do

  print*, ans 

end program main


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

#define         sf          scanf
#define         pf          printf
#define         mx          100005
#define         READ        freopen("in.txt", "r", stdin);
#define         inf         0x3f3f3f3f

using namespace std;

int n, k, h[mx], dp[mx];

int main()
{
	// READ

	memset(dp, inf, sizeof(dp));

	sf("%d %d", &n, &k);

	for(int i = 0; i < n; i++) sf("%d", h+i);

	dp[0] = 0;

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

	pf("%d\n", dp[n-1]);


	return 0;
}

Measured memory_bytes: 1024
n = int(input())
R = list(map(int,input().split()))

def trace():
    for i in range(len(R)):
        if i != len(R) - 1:
            print(R[i],end=' ')
        else:
            print(R[i])

count = 0
for i in range(0,n):
    minj = i
    for j in range(i,n):
        if R[j] < R[minj]:
            minj = j

    R[i],R[minj] = R[minj],R[i]
    if i != minj:
        count += 1
    


trace()
print(count)


Measured memory_bytes: 5612
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
using namespace std;
//printfを用いないと

int n;
vector<pair<int,int>> vec;
int n_=1;//nの階乗

double distance(pair<int,int> p1,pair<int,int> p2){
    double tmp = pow(p1.first-p2.first,2) + pow(p1.second-p2.second,2);
    tmp = pow(tmp,0.5);
    return tmp;
}
void init(){
    cin>>n;
    for(int i=1;i<n+1;i++)n_*=i;
    for(int i=0;i<n;i++){
        int x,y;cin>>x>>y;
        vec.push_back(make_pair(x,y));
    }
}
double solve(){
    double ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans += distance(vec[i],vec[j]) * (n_/n) * 2;
        }
    }
    ans /= n_;
    return ans;
}

int main(){
    init();
    double ans = solve();
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256