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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
/*
think fast
think simple
*/
void mysol()
{
	int n;
	cin >> n;
	int num = 0;
	int ans = 0;
	while (num == 0 or num % 360 != 0)
		num += n, ans++;
	cout << ans;
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3636
_ = input()
a = list(map(int, input().split()))

count = 0
for i in range(len(a)):
    minj = i
    for j in range(i+1, len(a)):
        #print('taiget {} in list {}'.format(a[i], a[j:]))
        if a[j] < a[minj]:
            minj = j
    #print('change[{}] to [{}]'.format(a[i], a[minj]))
    if a[i] != a[minj]:
        a[i], a[minj] = a[minj], a[i]
        count += 1

print(' '.join(map(str, a)))
print(count)



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

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

  for(int i=0;i<S.size();i++){
    if('Z'-S.at(i)>=N){
      S.at(i)= (char) (S.at(i)+N);
    }else{
      S.at(i)= (char) (S.at(i)+N-26);
    }
    cout << S.at(i);
  }

  cout << endl;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    bitset<100> A;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int k;
            cin >> k;
            A.set(k-1);
        }        
    }
    
    cout << N - A.count() << endl;
    
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;

  int k = 0;

  while(true){
    if(A == B && B == C){
      cout << k << endl;
      return 0;
    }
    int abs_1 = abs((A+1) - (B+1)) + abs((A+1) - C) + abs((B+1) - C);//A,Bを1増やす
    int abs_2 = abs((A+1) - B) + abs((A+1) - (C+1)) + abs(B - (C+1));//A,Cを1増やす
    int abs_3 = abs(A - (B+1)) + abs(A - (C+1)) + abs((B+1) - (C+1));//B,Cを1増やす
    int abs_4 = abs((A+2) - B) + abs((A+2) - C) + abs(B - C);//Aを選んで2増やす
    int abs_5 = abs(A - (B+2)) + abs(A - C) + abs((B+2) - C);//Bを選んで2増やす
    int abs_6 = abs(A - B) + abs(A - (C+2)) + abs(B - (C+2));//Cを選んで2増やす

    int minimum = min({abs_1,abs_2,abs_3,abs_4,abs_5,abs_6});
    if(abs_1 == minimum){
      A++;
      B++;
    }
    else if(abs_2 == minimum){
      A++;
      C++;
    }
    else if(abs_3 == minimum){
      B++;
      C++;
    }
    else if(abs_4 == minimum){
      A+=2;
    }
    else if(abs_5 == minimum){
      B+=2;
    }
    else if(abs_6 == minimum){
      C+=2;
    }
    k++;
  }


}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
flag = 0
for i in range(N):
    if A[i]%2==0:
        if A[i]%3==0 or A[i]%5==0:continue
        else:
            flag=1
            break
if flag==0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38332
#include <iostream>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)


using namespace std;

#define MAX_N 12
#define MAX_M 12

const int INF = 1001001001;


int main() {
    int N, M, X;
    int A[MAX_N][MAX_M];
    int C[MAX_N];
    int understand[MAX_M];
    
    

    scanf("%d %d %d", &N, &M, &X);
    //printf("N = %d M = %d X = %d\n", N, M, X);
    for (int i = 0; i < N; i++) {
        scanf("%d", &C[i]);
        //printf("C[%d] = %d\n", i, C[i]);
        for (int j = 0; j < M; j++) {
            scanf("%d", &A[i][j]);
            //printf("A[%d][%d] = %d\n", i, j, A[i][j]);
        }
    }

    
    int answer = INF;

    for (int s = 0; s < 1 << N; s++) { // 不等号を忘れずに
        int cost = 0; // ループするたびにcost をリセットしておく必要がある
        for (int j = 0; j < M; j++) { // ループするたびに理解度をリセットする
            understand[j] = 0;
        } 
        // vector<int> understand(M);
        for (int i = 0; i < N; i++) {
                if (s >> i & 1) {
                    cost += C[i];
                    for (int j = 0; j < M; j++) { // costを足したら，M 回理解度も足す
                        understand[j] += A[i][j];
                    }
                }
        }
    bool ok = true;
    for (int j = 0; j < M; j++) {
        if (understand[j] < X) ok = false; //途中どこかでokがfalseになると，以降もずっとfalseのまま (値がリセットされない)
    }

    if (ok) {
        answer = min(answer, cost);
    }
    }
    if (answer == INF) answer = -1; //answer の値が更新されない → ok = false → 理解度がX以下が少なくとも一つあり

    printf("%d\n", answer);

    return 0;

}

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

using namespace std;
#define ll long long int
#define mod 1000000007

int main(){
    ll n ,m;
    cin >> n >> m;
    char a[n][m];
    ll dp[n][m];
    memset(dp , 0 , sizeof(dp));
    dp[0][0] = 1;

    for(int i = 0;i < n ; i ++)
    {
        for(int j = 0; j  <m ; j ++)
        {
            cin >> a[i][j];
            
        }
    }
    for(int i = 1; i < m ; i ++)
    {
        if(a[0][i] == '.')
        dp[0][i] = 1;
        else
        break;
    }
    for(int j = 1; j < n ; j ++)
    {
        if(a[j][0] == '.')
        dp[j][0] = 1;
        else
        break;
    }
    for(int i = 1; i < n ; i ++)
    {
        for(int j = 1; j < m ; j ++)
        {
            if(a[i][j] == '.')
            {
                dp[i][j] = dp[i - 1][j] % mod + dp[i][j - 1] % mod;
                dp[i][j] %= mod;
            }
            else
            dp[i][j] = 0;
        }
    }
    cout << dp[n - 1][m - 1] % mod << endl;
}

Measured memory_bytes: 9088
// AOJ 0501: Data Conversion
// 2017.10.25 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char t['z'+1];
char s[100005], *p;

int main()
{
	int n, m, i;
	char b[33];

	while (fgets(b, 32, stdin) && *b != '0') {
		for (i = '0'; i <= 'z'; i++) t[i] = i;
		n = atoi(b);
		while (n-- > 0) {
			fgets(b, 32, stdin);
			t[*b] = *(b+2);
		}
		fgets(b, 32, stdin);
		m = atoi(b); p = s;
		while (m-- > 0) {
			fgets(b, 32, stdin);
			*p++ = t[*b];
		}
		*p = 0;
		puts(s);
	}
	return 0;
}

Measured memory_bytes: 1800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<(n);++i)
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define out(i) cout<<i<<endl;
#define m_p make_pair
#define m_t make_tuple
#define Vec vector
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef vector<pair<int,int>> VP;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}
int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
const ll INF=1ll<<60;
const ll MOD=1e9+7;

signed main(){
  int n,k;
  cin>>n>>k;
  V a(n);
  rep(i,n)cin>>a[i];
  SORT(a);
  bool can=true;
  if(a[n-1]<k)can=false;
  int res=a[0];
  rep(i,n){
    res=gcd(a[i],res);
  }
  if(k%res!=0)can=false;
  cout<<(can?"POSSIBLE":"IMPOSSIBLE")<<endl;
  
  
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll ans = 0;
    ll h, w, n;
    cin >> h >> w >> n;
    ll t = max(h, w);
    while (n > 0)
    {
        n -= t;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
public class
Main
{
  static final int[ ][ ] swp = { { 1, 4 }, { 0, 2, 5 }, { 1, 3, 6 }, { 2, 7 }
                               , { 0, 5 }, { 1, 4, 6 }, { 2, 5, 7 }, { 3, 6 } };

  private void
  run (
    )
  {
    java.util.Map<String, Integer> rec = new java.util.TreeMap<String, Integer> ( );
    java.util.Queue<Status> lis = new java.util.LinkedList<Status> ( );
    java.util.Scanner sc = new java.util.Scanner ( System.in );
    int i;
  
    lis.add ( new Status ( new int[ ]{ 0, 1, 2, 3, 4, 5, 6, 7 }, 0 ) );
    while ( !lis.isEmpty ( ) )
    {
      final Status s = lis.remove ( );
      int zp;
      
      if ( rec.containsKey ( java.util.Arrays.toString ( s.st ) ) )
        continue ;

      rec.put ( java.util.Arrays.toString ( s.st ), s.vl );
      for ( zp = 0; s.st[ zp ] != 0; ++zp ) ;
      for ( i = 0; i < swp[ zp ].length; ++i )
      {
        int[ ] ns = s.st.clone ( );
        
        ns[ zp ] = ns[ swp[ zp ][ i ] ];
        ns[ swp[ zp ][ i ] ] = 0;
        lis.add ( new Status ( ns, s.vl + 1 ) );
      }
    }

    while ( sc.hasNextInt ( ) )
    {
      int[ ] d = new int[ 8 ];
      
      for ( i = 0; i < 8; ++i )
        d[ i ] = sc.nextInt ( );

      System.out.println ( rec.get ( java.util.Arrays.toString ( d ) ) );
    }
  
    return ;
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( );

    return ;
  }

  private class
  Status
  {
    int[ ] st;
    int    vl;

    Status (
      int[ ] st,
      int    vl
      )
    {
      this.st = st;
      this.vl = vl;
      
      return ;      
    }
  }
}

Measured memory_bytes: 54936
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int right[26] = {};
	for (int i = 7; i <= 15; i++) {
		right[i] = 1;
	}
	right[20] = 1; right[24] = 1;
	string s;
	while (cin >> s) {
		if (s == "#")break;
		int len = s.length();
		int count = 0;
		for (int i = 0; i < len-1; i++) {
			if (right[s[i]-'a'] != right[s[i + 1]-'a'])count++;
		}
		cout << count << endl;
	}
	return 0;
}


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

using namespace std;
int main(){
	int n,k,x;
	cin>>n>>k;
	int now=0;
	int ans1=0;
	int ans2=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		now+=x;
		if(now<=k) ans2++;
	}
	cout<<ans2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    return 0;
}




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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    rep(a,10) {
        rep(b,10) {
            rep(c,10) {
                char d1 = '0' + a;
                char d2 = '0' + b;
                char d3 = '0' + c;
                bool t1,t2,t3;
                t1 = t2 = t3 = false;
                rep(i,N) {
                    if (d1==S[i] && t1==false) {
                        t1 = true;
                    }
                    else if (d2==S[i] && t2==false && t1==true) {
                        t2 = true;
                    }
                    else if (d3==S[i] && t3==false && t1==true && t2==true) {
                        t3 = true;
                    }
                }
                if (t3) ans++;
                //if (t3) cout << d1 << d2 << d3 << endl;
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{
    string n;
    cin >> n;
    rep(i, n.length())
    {
        if (n[i] == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3548
fun main(args: Array<String>) {
    readLine()!!.toInt()
    val x = readLine()!!.split(" ").map(String::toInt)
    val y = readLine()!!.split(" ").map(String::toInt)
    println(x.zip(y) { a, b -> Math.abs(a - b) }.sum())
    println(Math.sqrt(x.zip(y) { a, b -> Math.pow(Math.abs(a - b).toDouble(), 2.0) }.sum()))
    println(Math.cbrt(x.zip(y) { a, b -> Math.pow(Math.abs(a - b).toDouble(), 3.0) }.sum()))
    println(x.zip(y) { a, b -> Math.abs(a - b) }.max())
}


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(A == B && B == C) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<vector<pair<int,llint>>>go;
vector<llint>saigo;//最後に残る連結の和
void dfs(int ter,int per,llint suu){
	saigo[ter]=suu;
	for(auto it:go[ter]){
		if(it.fir==per||it.sec>suu){continue;}
		dfs(it.fir,ter,suu);
	}
}
int main(void) {
	//全域木->セグ木
	int n,m,i,ans=0;cin>>n>>m;
	
	vector<llint>X(n);
	for(i=0;i<n;i++){cin>>X[i];}
	vector<tuple<llint,int,int,llint>>hen(m);
	for(i=0;i<m;i++){
		int a,b;llint y;cin>>a>>b>>y;a--;b--;
		hen[i]=mt(y,a,b,0LL);
	}
	
	vector<int>uni(n);
	for(i=0;i<n;i++){uni[i]=i;}
	vector<int>ran(n);
	vector<llint>owa=X;
	go.res(n);saigo.res(n);
	vector<tuple<llint,int,int,llint>>zen;
	vector<tuple<llint,int,int,llint>>ato;
	SO(hen);
	for(i=0;i<m;i++){
		int a,b;llint y;llint gm;
		tie(y,a,b,gm)=hen[i];
		int aa=a,bb=b;
		while(a!=uni[a]){a=uni[a];}
		while(b!=uni[b]){b=uni[b];}
		if(a==b){ato.pub(hen[i]);continue;}
		if(ran[a]<ran[b]){swap(a,b);}
		if(ran[a]==ran[b]){ran[a]++;}
		owa[a]+=owa[b];
		if(owa[a]>=y){get<3>(hen[i])=owa[a];}
		uni[b]=a;
		zen.pub(hen[i]);
		
		go[aa].pub(mp(bb,y));
		go[bb].pub(mp(aa,y));
	}
	REV(zen);//高い方から
	for(i=0;i<zen.size();i++){
		int a,b;llint y;llint ok;
		tie(y,a,b,ok)=zen[i];
		if(saigo[a]!=0){continue;}
		if(ok){dfs(a,-1,ok);continue;}
		ans++;//cerr<<"dme "<<a<<b<<endl;
	}
	for(i=0;i<ato.size();i++){
		int a,b;llint y;llint ok;
		tie(y,a,b,ok)=ato[i];
		if(y>min(saigo[a],saigo[b])){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    ll D, G;
    cin >> D >> G;
    vector<ll> p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];


    ll res = 1001;
    for(ll i=0; i<(1<<D); i++) {
        ll temp = 0;
        ll tcnt = 0;
        ll mxj = -1;
        for(ll j=0; j<D; j++) {
            if(i & (1<<j)) {
                temp += 100*(j+1)*p[j] + c[j];
                tcnt += p[j];
            }
            else mxj = j;
        }
        if(mxj != -1) {
            ll tp = p[mxj]-1;
            if(temp<G && temp+(100*(mxj+1))*tp>=G) {
                ll t = G-temp;
                if(t%(100*(mxj+1))) tcnt += t/(100*(mxj+1)) + 1;
                else tcnt += t/(100*(mxj+1));
                res = min(res, tcnt);
            } else if(temp >= G) res = min(res, tcnt);
        } else if(temp >= G) res = min(res, tcnt); 
    }

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

Measured memory_bytes: 256
import collections

N = int(input())
S = [input() for _ in range(N)]

cnt = collections.Counter(S)
max_cnt = max(cnt.values())

ans_list = []

for key, value in cnt.items():
    if value == max_cnt:
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')



Measured memory_bytes: 38908
from fractions import gcd

def lcm(x, y):
    return x * y // gcd(x, y)

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(j, L)
        if m < L:
            print(0)
            break
    else:
        print((m // L + 1) // 2)
else:
    print(0)


Measured memory_bytes: 16316
MOD = 1000000007

N = int(input())
if N < 3:
  print(0)
else:
  fac,finv,inv = [1,1], [1,1], [1,1]

  for i in range(2, N + 1):
    tmp = fac[i - 1] * i % MOD
    fac.append(tmp)
    tmp = MOD - inv[MOD%i] * (MOD // i) % MOD
    inv.append(tmp)
    tmp = finv[i - 1] * inv[i] % MOD
    finv.append(tmp)

  def com(n,k):
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
  ret = 1
  M = N // 3
  for i in range(2, M+ 1):
    S = N - 3 * i
    ret += com(S + i - 1, i - 1 )
    ret = ret % MOD
  print(ret)

Measured memory_bytes: 9232
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

int main(){
    int N;cin>>N;
    vector<PLL>b(N);
    
    REP(i,N){
        LL a;
        cin>>a;
        b[i]=MP(a,i);
    }
    SORT(b);
    int cnt=0;
    REP(i,N){
        auto p=b[i];
        if(i%2!=p.second%2)cnt++;
    }
    cout<<cnt/2<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sidha(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int> 
#define pb push_back

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
	int n;cin>>n;
	int arr[n];
	ll sum=0,c=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	ll m=INT_MAX;
	for(int i=0;i<n;i++){
		c+=arr[i];
		int x=sum-c;
		m=min(abs(x-c),m);
	}
	cout<<m<<endl;
	return 0;
}

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

int main()
{
    long long int a,b,v,w,t,d,e;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    d=abs(a-b);
    e=(v-w)*t;
    if(d<=e)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>

typedef unsigned int ui;

void swap(ui & a, ui & b)
{
	unsigned int tmp = a;
	a = b;
	b = tmp;
}

ui gcd(ui a, ui b)
{
	if (a < b) swap(a, b);

	ui c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}

int main() {
	using namespace std;

	ui a, b;
	while (cin >> a >> b) {
		const ui GCD = gcd(a, b);
		const ui LCM = (a / GCD) * (b / GCD) * GCD;
		cout << GCD << ' ' << LCM << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int ans[100][100];

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    VI a(n);
    REP(i,n) cin >> a[i];

    int x = 0, y = 0;
    REP(i,n){
        REP(j,a[i]){
            ans[x][y] = i+1;
            if (x % 2 == 0) y++;
            else y--;
            if (y == w){
                y = w-1;
                x++;
            }
            if (y == -1){
                y = 0;
                x++;
            }
        }
    }

    REP(i,h){
        REP(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n;
	scanf("%d", &n);
	int s=0;
	int tmp = n;
	while (tmp) {
		s += tmp % 10;
		tmp /= 10;
	}
	puts(n%s ? "No\n" : "Yes\n");
}

Measured memory_bytes: 128
A = [list(map(int,input().split())) for i in range(3)]

ans = 0
for i in range(101):
    b1 = A[0][0] - i
    b2 = A[0][1] - i
    b3 = A[0][2] - i
    a2_1 = A[1][0] - b1
    a2_2 = A[1][1] - b2
    a2_3 = A[1][2] - b3
    a3_1 = A[2][0] - b1
    a3_2 = A[2][1] - b2
    a3_3 = A[2][2] - b3
    if (a2_1 == a2_2) and (a2_2 == a2_3) and (a2_3 == a2_1) and (a3_1 == a3_2) and (a3_2 == a3_3) and (a3_3 == a3_1):
        ans += 0        
    else:
        ans += 1
if ans != 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] r = new int[n];
        for (int i = 0; i < n; i++) {
            r[i] = in.nextInt();
        }

        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, r[i] - min);
            min = Math.min(min, r[i]);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 101524
def main():
    n,t = map(int,input().split())
    a = [int(x) for x in input().split()]
    a_min = []
    ap = a_min.append
    ap(a[0])
    for i in range(1,n):
        ap(min(a_min[-1],a[i]))
    a_sub = []
    ap = a_sub.append
    for i in range(n):
        ap(a[i]-a_min[i])
    print(a_sub.count(max(a_sub)))
if __name__ == "__main__":
    main()

Measured memory_bytes: 65300
from collections import Counter

n = int(input())
*arr, = map(int, input().split())
arr.sort()
mx = max(arr)
is_enabled = [1] * (mx + 1)

counter = Counter(arr)
for val, cnt in counter.items():
    if cnt > 1:
        is_enabled[val] = 0

for i, v in enumerate(arr):
    if i == 0 or arr[i - 1] != v:
        x = v * 2
        while x <= mx:
            is_enabled[x] = 0
            x += v

cnt = 0
for v in arr:
    if is_enabled[v]:
        cnt += 1
print(cnt)







Measured memory_bytes: 126280
N, D = map(int, input().split())
x = []
y = []
for i in range(N):
    coords = list(map(int, input().split()))
    x.append(coords[0])
    y.append(coords[1])

count = 0
for i in range(N):
    if (x[i]**2 + y[i]**2) ** 0.5 <= D:
        count += 1

print(count)

Measured memory_bytes: 96748
#include <iostream>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int main() {
  	ios::sync_with_stdio(false);
  	string a;
  	cin>>a;
  	for(int i=0;i<3;i++){
  		if(a[i]=='7')return cout<<"Yes\n",0;
  	}
  	cout<<"No\n";
 	return 0;
}

Measured memory_bytes: 3040
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
    n,a,b = map(int,input().split())
    print(n//(a+b)*a + min(a,n%(a+b)))

main()


Measured memory_bytes: 67180
S=list(input())
N=len(S)
ls=[0 for _ in range(N)]
mod=[0 for _ in range(2019)]
d=10
ls[0]=int(S[-1])
mod[ls[0]]+=1
for i in range(1,N):
  ls[i]=(ls[i-1]+d*int(S[-1-i]))%2019
  d=(d*10)%2019
  mod[ls[i]]+=1
#print(ls)
#print(mod)  
ans=mod[0]
for i in range(N):
  m=ls[i]
  mod[ls[i]]-=1
  ans+=mod[ls[i]]
print(ans)

Measured memory_bytes: 17892
#include "bits/stdc++.h"
#define rep(var,cnt) for(int (var)=0; (var)<(cnt); ++(var))

using namespace std;

using pi=pair<int,int>;

int main() {
	int N; cin>>N;
	vector<pi> aw(N);
	vector<int> aa(N),ww(N);
	rep(i,N) cin>>aa[i];
	rep(i,N) cin>>ww[i];
	rep(i,N) aw[i]=pi(aa[i],ww[i]);
	vector<int> index(N);
	iota(index.begin(),index.end(),0);
	
	int ans=INT_MAX;
	do{
		int tmp=0;
		rep(i,N){
			if(aw[index[i]].first==0){
				if(aw[index[(i+1)%N]].first==1){
					tmp+=aw[index[i]].second;
					//cout<<"  "<<index[i]<<" fuman "<<aw[index[i]].second<<endl;
				}
			}
			else{
				if(aw[index[(i-1+N)%N]].first==0){
					tmp+=aw[index[i]].second;
					//cout<<"  "<<index[i]<<" fuman "<<aw[index[i]].second<<endl;
				}
			}
		}
		if(tmp<ans){
			ans=tmp;
			/*rep(i,N){
				cout<<index[i];
			}
			cout<<endl;*/
		}
	}while(next_permutation(index.begin(),index.end()));
	cout<<ans<<endl;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	

	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		System.out.println((sum(b-a)-a));
	}
	public static int sum(int in){
		int ans=0;
		for(int i=1;i<in;i++){
			ans=ans+i;
		}
		return ans;
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int ma = 0, mi = 999;
  for (int i=0; i<5; i++) {
    cin >> a;
    ma = max(ma, a); 
    mi = min(mi, a);
  }
  int dist = ma - mi;
  int k;
  cin >> k;
  if (dist <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

int main()
{
    long N;
    std::cin >> N;
    std::string S;
    std::cin >> S;

    for(long i=0; i<S.length(); i++){
        char trans=S[i];
        trans+=N;
        if(trans>'Z'){
            trans=trans-'Z'-1+'A';
        }
        std::cout << trans;
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type ByValue []float64

func (s ByValue) Len() int           { return len(s) }
func (s ByValue) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s ByValue) Less(i, j int) bool { return s[i] < s[j] }

func input() string {
	var s string
	_, _ = fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	_, _ = fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())
	//total := 0
	//cnt := 0
	//for true {
	//	total += a
	//	if cnt > 0 {
	//		total--
	//	}
	//	cnt++
	//	if total >= b {
	//		break
	//	}
	//}
	//fmt.Println(total)
	//fmt.Println(cnt)
	res := math.Ceil(float64(b - a) / float64(a - 1)) + 1
	fmt.Println(res)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N;
vector<ll> A(200005);

int main() {
	cin >> N;
	rep (i, N) cin >> A[i];

	ll cnt = 0;
	int _max = A[0];
	rep2 (i, 1, N) {
		cnt += max(0LL, _max - A[i]);
		if (A[i] > _max) _max = A[i];
	}

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

Measured memory_bytes: 4748
#include <bits/stdc++.h>
#include <stdio.h>
#include <climits>

using namespace std;
inline int abs(int a, int b){
    if(a > b) return a - b;
    return b - a;
}
/*int FrogDP(int* a, int n){    //assume a is indexed from 1 
    
    int* ans = new int[n+1]; //a[i] denotes the answer for i heights
    ans[1] = 0; ans[2] = abs(a[1], a[2]);
    
    for(int i = 3; i<=n; i++){
        int option1 = abs(a[i], a[i-1]) + ans[i-1];
        int option2 = abs(a[i], a[i-2]) + ans[i-2];
        ans[i] = min(option2, option1);
    }
    
    return ans[n];
}*/

int FrogDPK(int* a, int n, int k){
    
    int* ans = new int[n+1];
    ans[1] = 0;
    for(int i = 2; i <= (k+1); i++){
        ans[i] = abs(a[1], a[i]);
    }
    
    
    for(int i = k + 2; i<=n; i++){
        int m = INT_MAX;
        for(int j = i - 1; j>=(i - k); j--){
            m = min(m, abs(a[i], a[j]) + ans[j]);
        }
        ans[i] = m;
    }
    
    return ans[n];
}
int main() {
    int n, k, a[100002];
    cin >> n >> k;
    for(int i = 1; i<=n; i++) cin >> a[i];
    cout << FrogDPK(a, n, k) << endl;
}
    

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = input()
ans = s[0] + str(len(s) - 2) + s[-1]
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

signed main(){

  int n, k; cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  auto dp = make_vec<int>(111, n+1);
  dp[0] = a;
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < n; j++){
      dp[i+1][max(0LL, j - dp[i][j])]++;
      dp[i+1][min(n, j + dp[i][j] + 1)]--;
    }
    for(int j = 0; j < n-1; j++){
      dp[i+1][j+1] += dp[i+1][j];
    }
  }

  k = min(100LL, k);
  for(int i = 0; i < n; i++){
    cout << dp[k][i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 180148
#!/usr/bin/env python3
import sys


def solve(L: int):
    print((L/3)**3)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)

if __name__ == '__main__':
    main()


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    int m; cin>>m;
    while(m--)
    {
        string s; cin>>s;
        set<string> st;
        for(int i=1;i<s.size();i++){
            string s1=s.substr(0,i);
            string s2=s.substr(i,s.size());

            st.insert(s1+s2); st.insert(s2+s1);
            reverse(ALL(s1));
            st.insert(s1+s2); st.insert(s2+s1);
            reverse(ALL(s2));
            st.insert(s1+s2); st.insert(s2+s1);
            reverse(ALL(s1));
            st.insert(s1+s2); st.insert(s2+s1);
        }
        cout<<st.size()<<endl;
    }
}

Measured memory_bytes: 3100
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void solv() {

	int n;
	cin >> n;
	ll w[110];
	for (size_t i = 0; i < n; i++)
	{
		cin >> w[i];
	}

	ll sum[110];
	sum[0] = w[0];
	for (size_t i = 1; i < n; i++)
	{
		sum[i] = w[i] + sum[i - 1];
	}

	ll res = INF;
	for (size_t i = 0; i < n - 1; i++)
	{
		res = min(abs(sum[i] - (sum[n - 1] - sum[i])), res);
	}
	cout << res << endl;
}

int main() {
//	COMinit();
	solv();

	return 0;
}


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

int main() {
  long N, M;
  cin >> N >> M;
  vector<long> X(M);
  for (long i = 0; i < M; i++) cin >> X.at(i);
  sort(X.begin(), X.end());
  vector<long> V;
  for (long i = 0; i + 1 < M; i++) {
    V.push_back(X.at(i + 1) - X.at(i));
  }
  sort(V.rbegin(), V.rend());
  long ans = accumulate(V.begin(), V.end(), 0L);
  for (long i = 0; i < N - 1; i++) {
    if (i == V.size()) break;
    ans -= V.at(i);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

// int frog(vector<int> h, int i, int n)
// {
//     if (i == n - 1)
//         return 0;
//     if (i > n)
//         return INT_MAX;
//     // (abs(h[i + 1] - h[i]) + frog(h, i + 1, n), abs(h[i + 2] - h[i]) + i + 2 < n ? frog(h, i + 2, n) : INT_MAX);

//     int l = abs(h[i] - h[i + 1]) + frog(h, i + 1, n);
//     int r = INT_MAX;
//     if (i + 2 < n)
//         r = abs(h[i] - h[i + 2]) + frog(h, i + 2, n);

//     return min(l, r);
// }

int main()
{
    int n;
    cin >> n;
    vector<int> dp(n + 1);
    dp[0] = 0;
    vector<int> h;

    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        h.push_back(t);
    }
    dp[1] = abs(h[1] - h[0]);
    // dp[2] = min(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]));
    }
    // for (auto i : h)
    //     cout << i << " ";
    cout << dp[n - 1];
}

Measured memory_bytes: 3872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF INT_MAX
#define INFLL _I64_MAX
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
void number_split(int num, int a[], int *d)
{
	int i=0, adic=10;

	while(num>0){
		a[i++]=num%adic;
		num/=adic;
	}
	*d=i;
}
int main(void)
{
	int n, a, b, num[5], d, sum, ans=0;

	cin>>n>>a>>b;

	rep(i, n+1){
		number_split(i, num, &d);
		sum=0;
		rep(j, d){
			sum+=num[j];
		}
		if(sum>=a&&sum<=b) ans+=i;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    char buf[55][55]={};
    int dx[8] = {-1,-1,-1,0,0,1,1,1};
    int dy[8] = {-1,0,1,-1,1,-1,0,1};
    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++){
            cin>>buf[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++){
            if(buf[i][j]=='.'){
                for(int k = 0; k<8; k++){
                    int x = j + dx[k];
                    int y = i + dy[k];
                    if(x<=w&&x>=0&&y>=0&&y<=h&&buf[y][x]=='#'){
                        count++;
                    }
                    
                }
                buf[i][j] = count+'0';
            }
            count = 0;
        }
    }
    
    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++){
            if(j%w==0){
                cout<<endl;
            }
            cout<<buf[i][j];
        }
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int k, n;
  cin >> k >> n;

  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  int max = k - a[n - 1] + a[0];
  for (int i = 1; i < n; ++i) {
    int dis;
    dis = a[i] - a[i - 1];
    if (dis > max) {
      max = dis;
    }
  }

  cout << k - max << '\n';

  return 0;
}


Measured memory_bytes: 1024
fn main() {
    let n = read();
    let a: Vec<u32> = (0..n).map(|_| read()).collect();

    let mut min_value = Vec::new();
    for e in a.iter().rev() {
        let k = lower_bound(|&x| x>e, &min_value);
        if k == min_value.len() { min_value.push(e) }
        else { min_value[k] = e }
    }
    println!("{}", min_value.len());
}

fn lower_bound<T, F: Fn(&T)->bool>(f: F, a: &Vec<T>) -> usize {
    let mut l = 0;
    let mut r = a.len();
    while l != r {
        let m = (l+r) / 2;
        if f(&a[m]){ r = m   }
        else       { l = m+1 }
    }
    l
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}
fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}

Measured memory_bytes: 4352
N,T=list(map(int,input().split()))
a=[]
cost=9999
for i in range(N):
    a.append(list(map(int,input().split())))
    if a[i][0]<cost and a[i][1]<=T:
        cost=a[i][0]
        minnum=i
if cost == 9999:
    print("TLE")
else:
    print(cost)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define Mod 1000000007
#define INF 9e8
#define INFL 9e18
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define N 500005
#define fs first
#define sc second 
#define UNIVISITED 0
#define EXPLORED 1
#define VISITED 2
using namespace std;
typedef  long long int ll;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
typedef vector <ll> vi;

ll dp1[N],dp2[N],a1[N],a2[N];
int main()
{

ios::sync_with_stdio(false);
cin.tie(0);
ll n,k;
cin>>n>>k;
ll curr=1;
for(int i=1;i<=n;i++)
{
  ll a=curr*2;
  ll b=curr+k;
  curr=min(a,b);
}
cout<<curr<<endl;



return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int ret = 0;
    for(;;){
        string s;
        if(!(cin >> s)){
            cout << ret << endl;
            return 0;
        }
        
        int n = s.size();
        for(int i=0; i<n; ++i){
            if('0' <= s[i] && s[i] <= '9'){
                int j = i+1;
                while(j < n && '0' <= s[j] && s[j] <= '9')
                    ++ j;
                ret += atoi(s.substr(i, j-i).c_str());
                i = j;
            }
        }
    }
}

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

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

        int[] a = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int result = 0;
        for (int i = n - 1; i >= 0; i--){
            for (int j = 0; j < n; j++){
                a[j] = -a[j];
            }
            result = result - a[i];
        }
        System.out.println(result);


    }
}







Measured memory_bytes: 23124
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long x,y;
	cin >> x >> y;
	long ans = 0;
	
	if( abs(x) == abs(y)){
		if( x == y )
			ans = 0;
		else
			ans = 1;
	}
	else if( y == 0 ){
		if( x < 0 )
			ans = abs(x);
		else
			ans = abs(x)+1;
	}
	else if( abs(y) > abs(x) ){
		if( x < 0 ){
			x *= -1;
			ans++;
		}
		ans += abs(abs(y)-x);
		x = abs(y);
		if( y < 0 ){
			ans++;
			x *= -1;
		}
	
	}
	else{
		if( y < 0 && x < 0 )
			ans += abs( y - x);
		else if( y < 0 && x > 0 ){
			ans++;
			x *= -1;
			ans += abs( y - x );
		}
		else if( y > 0 && x < 0 ){
			ans+=abs(abs(y)-abs(x));
			ans++;
		}

		else{
			ans+=abs( y - x ) + 2 ;
		}

	}
	P(ans);
	ret 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))

zan = 0
ans = 0
for i in range(n):
    temp = b_list[i] + zan
    s = a_list[i]
    if s >= temp:
        ans += temp
        zan = 0
    elif s < temp and s >= zan:
        ans += s
        zan = temp - s        
    else:
        ans += s
        zan = b_list[i]

if zan > a_list[n]:
    ans += a_list[n]
else:
    ans += zan
        
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#include <algorithm> 
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 

bool is_prime(double x){
    int  y = (int)(x) ;
    int  k = (int)(sqrt(x)) ;
    for(int i = 2 ; i <= k ; i++){
        if(y % i == 0 ){
            return false ; ;
        }
    }
    return true ; 
}

int main() {
    double ans ;
    cin >> ans ;
    while(1){
        if(is_prime(ans)){
            break ;
        }
        else {
            ans++ ;
        }
    }
    cout << ans << endl ;
    
}

Measured memory_bytes: 3752