akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1000;
int N, M;
ll X[Nmax], Y[Nmax], Z[Nmax];

int main(){
	cin >> N >> M;
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i] >> Z[i];

	ll ans = -1e16;
	for(int k=0; k<8; k++){
		int s[3];
		vector<ll> x(N);
		for(int i=0; i<3; i++) s[i] = ((k>>i&1)<<1)-1;
		for(int i=0; i<N; i++) x[i] = s[0]*X[i]+s[1]*Y[i]+s[2]*Z[i];

		sort(x.begin(), x.end());
		reverse(x.begin(), x.end());
		ll tmp_ans = 0;
		for(int i=0; i<M; i++) tmp_ans += x[i];
		ans = max(ans, tmp_ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc,char* argv[]){
  int a,b;
  int num;

  while(scanf("%d %d",&a,&b) != EOF){
    num = gcd(a,b);
    printf("%d %d\n",num,num*(a/num * b/num));
  }
  
  return 0;
}

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

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

int main(){

	string s, p;
	cin >> s >> p;
	s = s + s;
	if (s.find(p) != -1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3216
A,B = gets.split.map(&:to_i)
S = gets.chomp.chars
if S[A] == '-' && S[0..A-1].all?{|s| s.match(/\d/)} && S[A+1..-1].all?{|s| s.match(/\d/)}
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;

 class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		
		for(int i =0 ;i<n ;i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		
		int sum =0;
		for(int i=0;i<k;i++) {
			sum=sum+arr[i];
		}
		System.out.println(sum);
	}

}


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

long f(long a) {
  if (a % 4 == 0) return a;
  if (a % 4 == 1) return 1;
  if (a % 4 == 2) return a + 1;
  if (a % 4 == 3) return 0;
}

int main() {
  long A, B;
  cin >> A >> B;
  cout << (f(A - 1) ^ f(B)) << "\n";
}

Measured memory_bytes: 256
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define peak        9223372036854775807 
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005
ll n,m,vis0[100005],vis1[100005],vis2[100005],vis3[100005],dis[100005];
vi v[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll i,j,k,l;
        cin>>n>>m;
        for(i=0;i<=n;i++)
        {
            vis0[i]=0;vis1[i]=0;vis2[i]=0;vis3[i]=0;
            dis[i]=peak;
        }
        for(i=0;i<m;i++)
        {
            cin>>k>>l;
            v[k].pb(l);
        }
        ll s,t;
        cin>>s>>t;
        queue<ll> q;
        q.push(s);
        dis[s]=0;
        vis0[s]=1;
        while(!q.empty())
        {
            ll x=q.front();
            q.pop();
            for(auto i:v[x])
            {
                if(vis1[i]==1)
                    continue;
                vis1[i]=1;
                for(auto j:v[i])
                {
                    if(vis2[j]==1)
                        continue;
                    vis2[j]=1;
                    for(auto k:v[j])
                    {
                        if(vis0[k]==1)
                            continue;
                        vis0[k]=1;
                        q.push(k);
                        dis[k]=min(dis[k],dis[x]+1);
                    }
                }
            }
        }
        if(dis[t]==peak)
            cout<<-1;
        else
            cout<<dis[t];
    }
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  int n;
  cin >> n;
  int ans=0;
  vector<int>vec(n);
  rep(i,n){
    cin>>vec[i];
  }
  int i=0;
  while(i<n){
    if(vec[i]==i+1){
      ans++;
      i+=2;
    }
    else i++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[(int)2e5];
int b[(int)2e5];
int main()
{
    long long n,h;
    cin >> n >> h;
    for(int i = 1;i<=n;i++)
        cin >> a[i]>>b[i];
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    reverse(b+1,b+1+n);
    reverse(a+1,a+1+n);
    int mx = a[1];
    int c=0;
    long long sum=0;
    for(int i = 1;i<=n && sum<h&&b[i]>mx;i++)
    {
        c++;
        sum+=b[i];
    }
    int p = max(0ll,(h - sum));
    c+=(p+mx-1)/mx;
    cout<<c;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> v(s.length(), 1);
  int ans = 0;
  for (int i = 0; i < (int)s.length(); ++i) {
    if (s[i] == 'T') {
      v[i] = -1;
    }
    ans += v[i];
    ans = max(0, ans);
  }
  cout << ans * 2 << endl;
}

Measured memory_bytes: 1412
#include<stdio.h>

int main()
{
    int N,i;
    int flag=0;
    scanf("%d",&N);
    for(i=1;i<=9&&flag==0;i++){
        if((N/i)< 10 && N%i==0){
            flag=1;
        }
    }
    if(flag==1)
        printf("Yes\n");
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n;
  cin >> n;
  int a[3], b[3];
  rep(i, 3) cin >> a[i];
  rep(i, 3) cin >> b[i];
  vector<ll> dp(n+1);
  iota(dp.begin(), dp.end(), 0);
  rep(i, 3) rep(j, n+1) {
    if (j-a[i] >= 0)
      chmax(dp[j], dp[j-a[i]]+b[i]);
  }
  ll m = dp[n];
  dp.clear();
  dp.resize(m+1);
  iota(dp.begin(), dp.end(), 0);
  rep(i, 3) rep(j, m+1) {
    if (j-b[i] >= 0)
      chmax(dp[j], dp[j-b[i]]+a[i]);
  }
  cout << dp[m] << endl;
  return 0;
}

Measured memory_bytes: 195584
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <climits>
using namespace std;

typedef pair<int,int> P;

P myMax(const P &x, const P &y){
  if(x.first == y.first && x.second < y.second ||
     x.first > y.first){
    return x;
  }
  return y;
}

const int MAX_N = 1 << 18;

int n;
P dat[2 * MAX_N - 1];

int inX[100002], inY[100002];
vector<int> t;

void init(int n_){
  n = 1;
  while(n < n_) n *= 2;
  for(int i = 0; i < 2 * n - 1; i++) dat[i] = P(INT_MIN, -1);
}

void update(int tk, int a){
  int k = tk + n - 1;
  if(dat[k].first == INT_MIN){
    dat[k] = P(a, t[tk]);
  }
  else{
    dat[k].first += a;
  }

  while(k > 0){
    k = (k - 1) / 2;
    dat[k] = myMax(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

int main(){
  int m, q;

  while(cin >> m >> q){
    set<int> st;
    map<int,int> mp;

    for(int i = 0; i < q; i++){
      cin >> inX[i] >> inY[i];
      st.insert(inX[i]);
    }

    init(st.size());
    t.clear();

    for(set<int>::iterator iter = st.begin(); iter != st.end(); iter++){
      t.push_back(*iter);
      update(t.size() - 1, 0);
      mp[*iter] = t.size() - 1;
    }

    int firstZero = -1;

    for(int i = 1; i <= m; i++){
      if(st.find(i) == st.end()){
        firstZero = i;
        break;
      }
    }

    for(int i = 0; i < q; i++){
      update(mp[inX[i]], inY[i]);

      P ans = dat[0];

      if(ans.first <= 0 && firstZero != -1){
        ans = myMax(ans, P(0, firstZero));
      }

      cout << ans.second << " " << ans.first << endl;
    }
  }
}

Measured memory_bytes: 15136
n = int(input())
A = list(map(int,input().split()))
cnt = 0
B = [False for _ in range(n)]
for i,a in enumerate(A):
    if A[a-1] == i+1 and B[i] == False:
        cnt+=1
        B[a-1] = True
    B[i] = True
print(cnt)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF=1e18,MOD=1e9+7;
bool comp(int a,int b){
  if(a%10==0)a+=9;
  if(b%10==0)b+=9;
  return a%10>b%10;
}
int main(){
  vector<int>a(5);
  for(int i=0;i<5;i++)cin>>a[i];
  sort(a.begin(),a.end(),comp);
  ll ans=0;
  for(int i=0;i<4;i++){
    if(a[i]%10!=0){
      a[i]-=a[i]%10;
      a[i]+=10;
    }
    ans+=a[i];
  }
  ans+=a[4];
  cout<<ans<<endl;

}

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

string alphabet = "abcdefghijklmnopqrstuvwxyz";

int main(){
	int n;
	cin >> n;
	vector<map<char,int>> mp(n);
	rep(i,n){
		string s;
		cin >> s;
		rep(j,s.size()){
			mp[i][s[j]]++;
		}
	}
	
	string ans;
	
	rep(j,27){
		int count = mp[0][alphabet[j]];
		rep(i,n){
			count = min(count, mp[i][alphabet[j]]);
		}
		if(count > 0){
			rep(i,count){
				ans += alphabet[j];
			}
		}
	}
	
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
h,w=map(int,input().split())
s=eval('list(input()),'*h)
r=range
for i in r(h):
  for j in r(w):
    c=0
    for a in r(i-1,i+2):
      for b in r(j-1,j+2):
        c+=all((min(a,b)>=0,a<h,b<w))and s[a][b]=='#'
    if s[i][j]=='.':s[i][j]=c
for a in s:print(*a,sep='')

Measured memory_bytes: 50780
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int calc(int x) {
  if (x % 2 == 0) {
    return x/2;
  } else {
    return 3*x+1; 
  }
}

signed main() {
  vector<int> used(10000000, 0);
  int s;
  cin >> s;
  used[s] = 1;
  for (int i = 0; i < used.size(); i++) {
    s = calc(s);
    if (used[s] == 1) {
      cout << i+2 << endl;
      return 0;
    } else {
      used[s] = 1;
    }
  }
}



Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    n %= 1000;
    if(n == 0) n = 1000;
    cout << 1000 - n << endl;
}

Measured memory_bytes: 3636
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  int res = 0;
  if (k - a <= 0) {
    cout << k << endl;
    return 0;
  } 
  else {
    res += k;
    k -= a;
  }
  if (k - b <= 0) {
    cout << a << endl;
    return 0;
  } else {
    k -= b;
    cout << a - k << endl;
    return 0;
  }
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3572
H1, M1, H2, M2, K = list(map(int, input().split()))
if M1 <= M2:
  all_time = (H2 - H1) * 60 + (M2 - M1)
else:
  all_time = (H2 - H1 - 1) * 60 + (60 + M2 - M1)

available_time = all_time - K
print(available_time)

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

int main() {
    int N;
    cin >> N;
    
    vector<string> s;
    vector<int> c;
    for(int i=0;i<N;i++){
        string t;
        cin >> t;
        bool f = true;
        for(int j=0;j<s.size();j++){
            if(s.at(j) == t){
                c.at(j)++;
                f = false;
                break;
            }
        }
        if(f){
            s.push_back(t);
            c.push_back(1);
        }
    }
    int M;
    cin >> M;
    
    for(int i=0;i<M;i++){
        string t;
        cin >> t;
        for(int j=0;j<s.size();j++){
            if(s.at(j) == t){
                c.at(j)--;
                break;
            }
        }
    }
    int max = 0;
    for(int i=0;i<c.size();i++){
        if(c.at(i) > max) max = c.at(i);
    }
    cout << max << endl;
}


Measured memory_bytes: 256
program ABC152F
    implicit none
    integer::N
    integer::MS(9,9)=0
    integer::i,j
    integer::ANS=0
    read*,N
    do i=1,N
        if(mod(i,10)/=0)then
            MS(S(i),mod(i,10))=MS(S(i),mod(i,10))+1
        endif
    end do
    do i=1,9
        do j=1,9
            ANS=ANS+MS(i,j)*MS(j,i)
        end do
    end do
    print"(i0)",ANS
contains
function S(Num)
    integer::num
    integer::k
    integer::S
    S=10
    do k=0,6
        if(NUM/10**k/=0)then
        S=min(S,NUM/10**k)
        endif
    end do
end function
end program ABC152F

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

const int MAXN = 3 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;

long long dp[MAXN][MAXN][2];

int arr[MAXN];
int n;

void update_dp(int lengh)
{
    for(int i = 0; i <= n - lengh; i++){
        long long ans1, ans2;
        ans1 = arr[i] + dp[lengh - 1][i + 1][1];
        ans2 = arr[i + lengh - 1] + dp[lengh - 1][i][1];

        dp[lengh][i][0] = max(ans1, ans2);

        dp[lengh][i][1] =  dp[lengh - 1][i + 1][0];

        if(ans2 > ans1) dp[lengh][i][1] = dp[lengh - 1][i][0];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);

    cin >> n;

    for(int i = 0; i < n; i++) cin >> arr[i];

    for(int i = 1; i <= n; i++) update_dp(i);

    cout << dp[n][0][0] - dp[n][0][1] << endl;


    return 0;
}



Measured memory_bytes: 85280
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int train[501][501];
int sum[501][501];

int get_sum(int y1, int x1, int y2, int x2){
	return sum[y2][x2] - sum[y1-1][x2] - sum[y2][x1-1] + sum[y1-1][x1-1];
}


int main(){
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		train[l][r]++;
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			sum[i][j] = train[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
		}
	}

	for (int i = 0; i < q; i++){
		int l, r;
		cin >> l >> r;
		cout << get_sum(l, l, r, r) << endl;
	}
	return 0;
}

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



int main(){
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

    long long n;
    cin >> n;
    bool flag = false;
    for(long long i=-300;i<=300;i++){
        for(long long j=i;j<=300;j++){
            if(pow(i,5)-pow(j,5)==n){
                flag = true;
                cout << i << j << endl;
                break;
            }
            if(pow(j,5)-pow(i,5)==n){
                flag = true;
                cout << j << " " <<  i << endl;
                break;
            }
        }
        if(flag) break;
    }
}


Measured memory_bytes: 4100
from collections import defaultdict

# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

def combination(a, b):
    if b > a - b:
        return combination(a, a - b)
    return fact[a] * ifact[b] * ifact[a-b]


K = int(input())
S = input().strip()
N = len(S)

# 階乗を前処理
fact = defaultdict(int)
fact[0] = 1
for i in range(1, N+K+1):
    fact[i] = fact[i-1] * i
    fact[i] %= MOD
# 階乗の逆元を前処理
ifact = defaultdict(int)
ifact[N+K] = pow(fact[N+K], MOD-2, MOD)
for i in reversed(range(1, N+K+1)):
    ifact[i-1] = ifact[i] * i
    ifact[i-1] %= MOD

ans = 0
for i in range(K+1):
    now = pow(26, K-i, MOD)
    now *= pow(25, i, MOD)
    now %= MOD
    now *= combination(i+N-1, N-1)
    now %= MOD
    ans += now
    ans %= MOD

print(ans)


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

typedef struct{
	int no;
	int time;
}team;

team aki[1000000],t;
int n,a,b,i,j;

int main(){
	
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		memset(aki,0,sizeof(aki));
		
		for(i=0;i<n;i++){
			scanf("%d",&aki[i].no);
			for(j=0;j<4;j++){
				scanf("%d%d",&a,&b);
				aki[i].time+=60*a+b;
			}
		}
		
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				if(aki[i].time>aki[j].time){
					t=aki[j];
					aki[j]=aki[i];
					aki[i]=t;
				}
			}
		}
		printf("%d\n%d\n%d\n",aki[0].no,aki[1].no,aki[n-2].no);
	}
	return 0;
}

Measured memory_bytes: 8576
h,w = map(int, raw_input().split())
mat = [list(raw_input()) for _ in range(h)]
rows = set([i for i in range(len(mat)) if '#' in mat[i]])

cols = set([i for i in range(len(mat[0])) if '#' in [mat[j][i] for j in range(len(mat))]])

mat = [mat[i] for i in range(len(mat)) if i in rows]


mat = [[mat[i][j] for j in range(len(mat[0])) if j in cols] for i in range(len(mat))]

for l in mat:
	print ''.join(l)


Measured memory_bytes: 85032
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] num = new int[M*2];
    int[] count = new int[N];

    for(int i=0; i < M*2; i++){
        num[i] = sc.nextInt();
        count[num[i]-1]++;
    }
    for(int i=0; i < N; i++){
        System.out.println(count[i]);
    }
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#define MAX 100
#define INF 1<<21

void bfs(int,int,int *);
void enqueue(int);
int dequeue();

int Ad[MAX][MAX],queue[MAX],head,tail,tas;

int main(){
  int n,i,j,u,k,v,visiter[MAX];
  
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++) Ad[i][j] = 0;
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      Ad[u][--v] = 1;
    }
  }
  bfs(0,n,visiter);

  return 0;
}

void bfs(int i,int n,int * visiter){
  int j,box,l;
  
  enqueue(i);
  for(j = 0;j < n;j++) visiter[j] = INF;
  visiter[i] = 0;
  while(tas != 0){
    box = dequeue();
    for(l = 0;l < n;l++){
      if(Ad[box][l] == 0) continue;
      if(visiter[l] != INF) continue;//INF ga kakikae rarete nai
      visiter[l] = visiter[box] + 1;
      enqueue(l);
    }
  }
  for(j = 0;j < n;j++){
    printf("%d ",j + 1);
    if(visiter[j] != INF) printf("%d\n",visiter[j]);
    else printf("-1\n");
      }
}


void enqueue(int n) {
  tas++;
  //  if(tail <= MAX) return -1;
  queue[tail++] = n;
}

int dequeue() {
  tas--;
  //  if(head >= tail) return -1;
  return queue[head++];
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;

ll H[1000000];
ll dp[1000000];

int main() {
  ll N;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  dp[0]=0;
  dp[1]=abs(H[0]-H[1]);
  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
  }
  cout<<dp[N-1];
}

Measured memory_bytes: 5120
#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;

 

}


Measured memory_bytes: 3112
import java.math.BigInteger;
        import java.util.*;
        import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        pw.println(1-n);
        pw.flush();
    }
    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}

Measured memory_bytes: 32880
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    cout << (m1 != m2) << endl;

    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
    }
    l.push_back(0);
    r.push_back(0);
    sort(l.rbegin(), l.rend());
    sort(r.begin(), r.end());
    ll ans = 0;
    ll sm = 0;
    for (int i = 0; i <= n; i++) {
        sm -= 2 * r[i];
        sm += 2 * l[i];
        ans = max(ans, sm);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int n; cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s; cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
       
    }
    ll ans = 0;
    for(auto p : mp){
        int s = p.second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;
    return 0;
    

}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  ll a,b,ans;
  IN2(a,b);
  if(abs(b-a)%2 == 1){
    OUT("IMPOSSIBLE");
  }
  else
  {
    ans = (a+b) / 2; 
    OUT(ans);
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,d,x,a[110];
  cin>>n>>d>>x;
  for(int i=0;i<n;i++)cin>>a[i];
  int re=0;
  for(int i=0;i<n;i++){
    if(d%a[i]!=0)re+=d/a[i]+1;
    else{re+=d/a[i];}
  }
  re+=x;
  cout<<re<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int r;
	cin >> r;
	if (r < 1200) cout<<"ABC"<<endl;
	else if (1200<=r && r < 2800) cout<<"ARC"<<endl;
	else cout << "AGC" << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

/*template*/
ll x(int n) {
	ll t = n;
	ll cnt = 0;
	while (t % 2 == 0) {
		cnt++;
		t /= 2;
	}
	return cnt;
}

int main() {
	ll N; cin >> N;
	ll a[100000];
	ll cnt = 0;
	rep(i, 0, N) {
		ll p; cin >> p;
		cnt += x(p);
	}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }



    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        long ans = 0;
        for (int i = 1; i < N; i++) {
            ans += i;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
# https://atcoder.jp/contests/abc084/tasks/abc084_d
from itertools import accumulate


def get_prime(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        return []
    if n == 2:
        return [2]
    prime = [2]
    limit = int(n ** 0.5)
    nums = [i + 1 for i in range(2, n, 2)]
    while True:
        p = nums[0]
        if limit < p:
            return prime + nums
        prime.append(p)
        nums = [e for e in nums if e % p != 0]


primes = set(get_prime(10 ** 5))
like = [0] * 10 ** 5
for i in range(3, 10**5):
    if i in primes and (i + 1) // 2 in primes:
        like[i] = 1

like_accum = list(accumulate(like))

q = int(input())
for _ in range(q):
    l, r = list(map(int, input().split()))
    result = like_accum[r] - like_accum[l-1]
    print(result)


Measured memory_bytes: 82340
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  static boolean[][] z = new boolean[22][22];
  static boolean[][] zz = new boolean[22][22];
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);

    int a[] = new int[3];
    s = r.readLine();
    sl = s.split(" ");
    a[0] = Integer.parseInt(sl[0]);
    a[1] = Integer.parseInt(sl[1]);
    a[2] = Integer.parseInt(sl[2]);

    s = r.readLine();
    int t[] = new int[100000];
    for(int i = 0; i < n; i++)
    {
      char c = s.charAt(i);
      if(c == 'r')
      {
        t[i] = 2;
      }
      else if(c == 's')
      {
        t[i] = 0;
      }
      else
      {
        t[i] = 1;
      }
    }

    int v[][] = new int[100000][3];
    for(int i = n - 1; i >= n - k; i--)
    {
      v[i][0] = (t[i] == 0 ? 0 : Math.max(t[i] == 1 ? a[1] : 0, t[i] == 2 ? a[2] : 0));
      v[i][1] = (t[i] == 1 ? 0 : Math.max(t[i] == 0 ? a[0] : 0, t[i] == 2 ? a[2] : 0));
      v[i][2] = (t[i] == 2 ? 0 : Math.max(t[i] == 0 ? a[0] : 0, t[i] == 1 ? a[1] : 0));
    }
    for(int i = n - k - 1; i >= 0; i--)
    {
      v[i][0] = Math.max(v[i + k][1] + (t[i] == 1 ? a[1] : 0), v[i + k][2] + (t[i] == 2 ? a[2] : 0));
      v[i][1] = Math.max(v[i + k][0] + (t[i] == 0 ? a[0] : 0), v[i + k][2] + (t[i] == 2 ? a[2] : 0));
      v[i][2] = Math.max(v[i + k][0] + (t[i] == 0 ? a[0] : 0), v[i + k][1] + (t[i] == 1 ? a[1] : 0));
    }

    int vv = 0;
    for(int i = 0; i < k; i++)
    {
      vv += Math.max(v[i][0], Math.max(v[i][1], v[i][2]));
    }

//    for(int i = 0; i < 3; i++)
//    {
//      for(int j = 0; j < n; j++)
//      {
//        System.out.printf("%5d ", v[j][i]);
//      }
//      System.out.println();
//    }

    System.out.println(vv);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 35852
A, B, C, D, E, F = map(int, input().split())
res = 0
ans = [100*A,0]# sugar+water, sugar

for x in range(F//(100*A)+1):
    for y in range((F-100*A*x)//(100*B)+1):
        if x == y == 0: continue
        sugarMAX = (A*x+B*y)*E
        M = F-100*A*x-100*B*y
        water = 100*A*x+100*B*y
        for z in range(M//C+1):
            for w in range((M-C*z)//D+1):
                sugar = C*z+D*w
                if sugar <= sugarMAX:
                    if ans[1]*(sugar+water) < sugar*ans[0]:
                        ans = [sugar+water, sugar]
                else:
                    break
print(*ans)

Measured memory_bytes: 73656
#include<bits/stdc++.h>
#define int long long
using namespace std;
 main()
{
    int k,a,b;
    cin>>k>>a>>b;
    for(int i =a; i<=b; i++){
        if(i % k == 0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;


	return 0;
}


Measured memory_bytes: 3592
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        Set<Character> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(line[i].charAt(0));
        }

        if (set.size() == 4) {
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }
}


Measured memory_bytes: 22996
import java.io.*;

class Main {
    public static void main(String[] arg)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] div = str.split(" ");
        int s =  Integer.parseInt(div[0]);
        int l =  Integer.parseInt(div[1]);
        System.out.println(s*l + " "+ 2*(s+l));
    }   
}
 

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  rep(i, n) {
    rep(j, i + 1) {
      swap(a[i], a[j]);
      if (is_sorted(a.begin(), a.end())) {
        cout << "YES" << endl;
        return 0;
      }
      swap(a[i], a[j]);
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a,b,c,x;
  cin >> a>>b>>c>>x;
  int ans=0; 

  rep(i,min(x/50,a)+1){
    rep(j, min((x-500*i)/100, b)+1){
      if((x-500*i-100*j)/50<=c)ans++;
    }
  }
  
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define min(a,b) (a>b)?b:a
#define max(a,b) (a>b)?a:b
#define inf 0x7fffffff
#define ll long long
#define maxn 10005
#define P(a,n) sort(a+1,a+1+n)
#define rt return
#define up(i,a,b) for(int i=a;i<=b;i++)
#define down(i,a,b) for(int i=a;i>=b;i--)
#define go continue 
#define clear(vis) memset(vis,0,sizeof vis)
#define end exit(0)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)
using namespace std;
int x;
int main(){
	scanf("%d",&x);
	printf("%d",1-x);

	return 0;
} 

Measured memory_bytes: 3824
#include <stdio.h>

int main(void){
  int n,a[100],i,j,minj,aa,sw=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
      aa=a[i];
      a[i]=a[minj];
      a[minj]=aa;
      if(minj!=i) sw+=1;
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i>=n-1)
      printf("\n");
    else
      printf(" ");
  }
  printf("%d\n",sw);

  return(0);
}



Measured memory_bytes: 2744
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.L;
		long ans2=n*(n-1)/2;
		Console.WriteLine("{0}",ans2);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ans = (a * b) / gcd(a, b);
    System.out.println(ans);
  }

  public static long gcd(long x, long y) {
    if(y == 0) return x;
    return gcd(y, (x % y));
  }
}

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

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            boolean ok = false;
            if (S.startsWith("YAKI")) ok = true;
            out.println(ok ? "Yes" : "No");

        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	int a[s.length()];
	memset(a,0,sizeof(a));
	for(int i=0;i<s.length();i++){
		if(s[i]=='R'){
			a[i]++;
			a[i+1]=a[i];
		}
		else
			a[i]=0;
		ans=max(ans,a[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
ll keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
ll keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
ll ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll func(ll n){
  return (n<10?n:func(n/10) );
}

int main(){
  ll N; cin >>N;
  ll k = keta(N);
  ll t = func(N);
  ll r = max(keta_wa(N), t-1+(k-1)*9 );
  cout << r <<"\n";
}

Measured memory_bytes: 256
L, R = [[], []]
N, M = map(int, input().split())
for i in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)

count = 0
minR = min(R)
maxL = max(L)
if minR < maxL:
  count = 0
else:
  for i in range(maxL, minR+1):
    if i <= N:
      count = count + 1
      
print('%d' % count)

Measured memory_bytes: 10996
#include<iostream>
#include<string>
#include<algorithm>
#include <map>  
#include <string.h>
#include <math.h>

using namespace std;



int main()
{	

	unsigned long long n, tmp1=1, tmp2=2, tmp;
	cin >> n;
	if (n == 1) {
		cout << "1" << endl;
		return 0;
	}

	for (int i = 2; i <= n; i++) {
		tmp = tmp1 + tmp2;
		tmp2 = tmp1;
		tmp1 = tmp;
	}
	cout << tmp << endl;
	return 0;
}

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

//#define MAX 10
#define MAX 2020

int n;
int X[110] = {0};
int m;
int A[110] = {0};
int BRD[MAX] = {0};

int main(void)
{
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> X[i];  
        BRD[X[i]] = 1;
    }

    cin >> m;
    for(int j=1;j<=m;j++){
        cin >> A[j];
    }

    for(int j=1;j<=m;j++){
        if(BRD[X[A[j]]+1] != 1 && X[A[j]] != (MAX-1)){
            BRD[X[A[j]]]=0;
            BRD[X[A[j]]+1] = 1;
            X[A[j]]++;
        }
    }

    for(int b=1;b<=MAX-1;b++){
        if(BRD[b] == 1){
            cout << b << endl;
        }
    }
}



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

typedef long long ll;
typedef long double ld;
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define pb push_back
#define _1 first
#define _2 second

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1000000007;
const int alphabet = 26;
const int MAXINT = 13;

int n, m, x, A[MAXINT][MAXINT], C[MAXINT];

int main(){
    riii(n,m,x);
    FOR(i,0,n){
        ri(C[i]);
        FOR(j,0,m) ri(A[i][j]);
    }

    ll ans = INFLL;
    FOR(i,0,(1ll<<n)){
        ll cost = 0, skills[m]={};
        FOR(j,0,n) if(i&(1ll<<j)){
            cost += C[j];
            FOR(k,0,m) skills[k] += A[j][k];
        }

        bool valid = true;
        for(int i=0; i<m && valid; i++) valid = bool(skills[i]>=x);
        if( valid ) ans = min( ans, cost );
    }

    printf("%lld\n", (ans==INFLL?-1: ans) );
}

/*

*/  

Measured memory_bytes: 3816
from collections import defaultdict
from collections import Counter
S = input()
T = input()
ans = "Yes"
s_dict = defaultdict(str)
t_dict = defaultdict(str)
# SとTが互いに単射であればYesそうでなければNo
for s,t in zip(S,T):
  if s_dict[t] != "" and s_dict[t] != s:
    ans = "No"
    break
  elif t_dict[s] != "" and t_dict[s] != t:
    ans = "No"
    break
  s_dict[t] = s
  t_dict[s] = t
print(ans)

Measured memory_bytes: 4016
s = input()
t = input()
r = len(s)
lon = len(t)
for i in range(len(s)-len(t)+1):
    c = 0
    for j in range(lon):
        if t[j]!=s[j+i]:
            c += 1
    if r >= c:
        r = c
print(r)

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#define REP(i,m,n) for(int i = (int)(m) ; i < (int) (n);i++)
#define rep(i,n) REP(i , 0 ,n)
using namespace std;

int n;
int c = 1;
string s;

int main() {
	cin >> n >> s;
	rep(i, n - 1){
		if (s[i] != s[i + 1]) c++;
	}

	cout << c << endl;


	return 0;
}


Measured memory_bytes: 512
import bisect
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sumA=[0]
for i in range(N):
  sumA.append(sumA[-1]+A[i])
sumB=[0]
for i in range(M):
  sumB.append(sumB[-1]+B[i])

ans=0
for i in range(N+1):
  k=K-sumA[i]
  if k<0:
    break
  l=bisect.bisect_right(sumB,k)-1
  ans=max(ans,i+l)
print(ans)

Measured memory_bytes: 47400
//01背包 
#include<bits/stdc++.h>
using namespace std;

const int N = 105;
long long f[100050];//滚动数组
long long v[N];//价值
int w[N];//重量
int n,m;
 
int main()
{
 	cin>>n;//物品种数
	cin>>m;//背包容量
	for(int i = 1;i<=n;++i){
		cin>>w[i]>>v[i];
	}
	
	memset(f,0,sizeof(f));
	for(int i = 1;i<=n;++i){//外层循环物品个数 
		for(int j = m;j>=w[i];--j){//内层循环背包体积 (从大到小循环） 
			f[j] = max(f[j],f[j-w[i]]+v[i]);
		}
	}
	cout<<f[m]<<endl;
	return 0;
} 

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

int dp[6000][6000];

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
int main(){
	int n;string s;cin>>n>>s;
	dp[0][0]=1;
	rep(i,n)rep(j,n){
		(dp[i+1][j+1]+=dp[i][j]*2)%=MOD;
		(dp[i+1][max(0,j-1)]+=dp[i][j])%=MOD;
	}
	cout<<(dp[n][s.size()]*ppow(ppow(2,s.size()),MOD-2))%MOD<<endl;
}

Measured memory_bytes: 119040
def main():
    S = input()
    T = input()
    ns = len(S)
    nt = len(T)

    dp = [[0]*(nt+1) for _ in [0]*(ns+1)]
    for i in range(ns+1):
        dp[i][0] = i
    for j in range(nt+1):
        dp[0][j] = j
    
    di_1 = dp[0]
    for s, di in zip(S, dp[1:]):
        j = 0
        di_1j_1 = di_1[0]
        dij_1 = di[0]
        for t in T:
            j += 1
            if s == t:
                dmin = di_1j_1
                di_1j = di_1[j]
            else:
                dmin = di_1j = di_1[j]
                if dij_1 < dmin:
                    dmin = dij_1
                if di_1j_1 < dmin:
                    dmin = di_1j_1
                dmin += 1
            di[j] = dij_1 = dmin
            di_1j_1 = di_1j
        di_1 = di
    
    print(dp[-1][-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 41888
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 long long int A;
 long long int B;
 cin >> A >> B;
long long int C = A * B;
 long long int tmp;
 long long int r;
 if(A < B){
    tmp = A;
    A = B;
    B = tmp;
  }
  r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
  cout << C/B << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string x,y;
    cin>>x>>y;
    if(x>y)
    cout<<">"<<endl;
    if(x==y)
    cout<<"="<<endl;
    if(x<y)
    cout<<"<"<<endl;
    return 0;
}

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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x,t;
    cin >>x>>t;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << max(x-t,0) << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256