akhauriyash/Code-Regression huggingface dataset:
class BinaryTree:
    class Node:
        def __init__(self):
            self.parent = -1
            self.sibling = -1
            self.degree = 0
            self.depth = 0
            self.height = 0
            self.children = []
            
            
    def __init__(self, n):
        self.nodes_num = n
        self.max_depth = 0
        self.nodes = [None] * n
        for i in range(self.nodes_num):
            node = self.Node()
            self.nodes[i] = node


    def load(self, node_info):
        for _node_info in node_info:
            node_num = _node_info[0]
            self.nodes[node_num].children.append(_node_info[1])
            self.nodes[node_num].children.append(_node_info[2])
            for child in self.nodes[node_num].children:
                if child != -1:
                    self.nodes[child].parent = node_num
            if not -1 in self.nodes[node_num].children:
                self.nodes[self.nodes[node_num].children[0]].sibling = self.nodes[node_num].children[1]
                self.nodes[self.nodes[node_num].children[1]].sibling = self.nodes[node_num].children[0]

                
    def _calc_depth(self, p):
        if self.nodes[p].parent == -1:
            return 0
        return 1 + self._calc_depth(self.nodes[p].parent) 

    
    def calc_depth(self):
        for i in range(self.nodes_num):
            self.nodes[i].depth = self._calc_depth(i)


    def _calc_height(self, p):
        h1, h2 = 0, 0
        if self.nodes[p].children[0] != -1:
            h1 = self._calc_height(self.nodes[p].children[0]) + 1
        if self.nodes[p].children[1] != -1:
            h2 = self._calc_height(self.nodes[p].children[1]) + 1
        return max(h1, h2)


    def calc_height(self):
        height = 0
        for i in range(self.nodes_num):
            self.nodes[i].height = self._calc_height(i)
    
    
    def print_nodes(self):
        for i in range(self.nodes_num):
            degree = len(self.nodes[i].children) - self.nodes[i].children.count(-1)
            if self.nodes[i].parent == -1:
                type = 'root'
            elif degree == 0:
                type = 'leaf'
            else:
                type = 'internal node'
            print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(i, self.nodes[i].parent, self.nodes[i].sibling, degree, self.nodes[i].depth, self.nodes[i].height, type ))


    def print_test(self):
        for i in range(self.nodes_num):
            print('node:' + str(i) + ' parent:' + str(self.nodes[i].parent) + ' sibling:' + str(self.nodes[i].sibling) + ' depth:' + str(self.nodes[i].depth) + ' height:' + str(self.nodes[i].height))


if __name__ == '__main__':
    n = int(input())
    node_info = []
    for _ in range(n):
        node_info.append(list(map(int, input().rstrip().split())))
    bt = BinaryTree(n)
    bt.load(node_info)
    bt.calc_depth()
    bt.calc_height()
    bt.print_nodes()


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

//SUN,MON,TUE,WED,THU,FRI,SAT

int main(){
  char a[5];
  int ans;
  scanf("%s", a);
  
  if(strcmp(a,"SUN")==0){
    ans = 7;
  }else if(strcmp(a,"MON")==0){
    ans = 6;
  }else if(strcmp(a,"TUE")==0){
    ans = 5;
  }else if(strcmp(a,"WED")==0){
    ans = 4;
  }else if(strcmp(a,"THU")==0){
    ans = 3;
  }else if(strcmp(a,"FRI")==0){
    ans = 2;
  }else if(strcmp(a,"SAT")==0){
    ans = 1;
  }
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
const int maxn=1e5+5;
int n;
vector<pair<int,int>> tree(8*maxn);
pair<int,int> merge(pair<int,int> a,pair<int,int> b,bool fl){
    vector<int> v={a.first,a.second,b.first,b.second};
    if(fl==0) sort(v.rbegin(),v.rend());
    else sort(v.begin(),v.end());
    return {v[0],v[1]};
}
void build(int v,int tl,int tr,bool fl=0){
    if(tl==tr){
        if(fl==0) tree[v]={-1,-1};
        else tree[v]={n,n};
        return ;
    }
    int mid=(tl+tr)>>1;
    build(2*v,tl,mid,fl);
    build(2*v+1,mid+1,tr,fl);
    tree[v]=merge(tree[2*v],tree[2*v+1],fl);
}
void update(int v,int tl,int tr,int pos,int val,int fl){
    if(pos > tr or pos < tl) return;
    if(tl==tr and pos==tl){
        tree[v].first=val;
        return;
    }
    int mid=(tl+tr)>>1;
    update(2*v,tl,mid,pos,val,fl);
    update(2*v+1,mid+1,tr,pos,val,fl);
    tree[v]=merge(tree[2*v],tree[2*v+1],fl);
}
pair<int,int> query(int v,int tl,int tr,int ql,int qr,bool fl){
    if(ql > qr or qr < tl or ql > tr){
        if(fl==0) return {-1,-1};
        else return {n,n};
    }
    if(tl>=ql and tr<=qr) return tree[v];
    int mid=(tl+tr)>>1;
    return merge(query(2*v,tl,mid,ql,qr,fl),query(2*v+1,mid+1,tr,ql,qr,fl),fl);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n;
    stack<int> s1;
    vector<int> p(n);
    for(int i=0;i<n;i++) {cin >> p[i];p[i]--;}
    vector<pair<int,int>> rpos(n),lpos(n);
    build(1,0,n-1,1);  
    update(1,0,n-1,p[n-1],n-1,1);
    rpos[n-1]={n,n};
    for(int i=n-2;i>=0;i--){
        rpos[i]=query(1,0,n-1,p[i]+1,n-1,1);
        update(1,0,n-1,p[i],i,1);
    }
    build(1,0,n-1,0);
    update(1,0,n-1,p[0],0,0);

    lpos[0]={-1,-1};
    for(int i=1;i<n;i++){
        lpos[i]=query(1,0,n-1,p[i]+1,n-1,0);
        update(1,0,n-1,p[i],i,0);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll cont=0;
        p[i]++;
        cont+=(rpos[i].second-rpos[i].first)*(i-lpos[i].first);
        cont+=(lpos[i].first-lpos[i].second)*(rpos[i].first-i);
        dbg(cont);
        ans+=cont*p[i];
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fip ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define reptUsual(b) for(i=0; i<b; ++i)
#define rept(i,a,b) for(i=a; i<b; ++i)
#define pb(a) push_back(a)
#define newln cout<<"\n"
#define bigPrime 1000000007
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
// continue // break // greater // string // length // while //iterator //first //second //size //begin //end
 
/*
void funct(int *dp,int *ar, int n){
    if( dp[n]!=0) return;
    else{
        int res=1;
        for(int i=n-1;i>=0;i--){
            
            if(ar[n]>ar[i]){
                funct(dp,ar,i);
                res=max(res, dp[i]+1);
            }
 
        }
        dp[n]=res;
    }
}

bool cmp(pair<int, int>& a, 
         pair<int, int>& b) 
{ 
    return a.second > b.second; 
}
*/

void dfs2(vector <vi> &v, vector<vi> &vis, vi &ancestors, int a,int b){

    
}


int dfs(vector <vi> &v, int n, vector<vi> &vis, vi &ancestors){
    int i,cnt=0;
    ancestors.pb(n);
    reptUsual(v[n].size()){
        if(vis[n][v[n][i]]==0)  {
            for(int j=0;j<ancestors.size();j++) if(ancestors[j]==v[n][i]){ dfs2(v,vis,ancestors,n,v[n][i]);}
            for(int j=0;j<ancestors.size();j++) vis[ancestors[j]][v[n][i]]=1;
            cnt+=dfs(v,v[n][i],vis,ancestors)+1;            
            
            }
    }
    return cnt;

}


int main()
{
    fip;
    int n,i,c=0;
    cin>>n;
    char ar[n];
    reptUsual(n){
        cin>>ar[i];
        if(ar[i]=='W')  c++;
    }
    int ans=0;
    for(i=n-c-1;i>=0;i--){
        if(ar[i]=='W')  ans++;
    }
    cout<<ans;



    return 0;
}

Measured memory_bytes: 3704
n,m=map(int,input().split())
s=list(map(int,list(input())))
ans=[]
i=n
while i>0:
  j=max(0,m-i)
  while s[i-(m-j)]!=0:
    j+=1
    if j==m:
      print(-1)
      exit(0)
  ans.append(m-j)
  i-=(m-j)
ans.reverse()
print(' '.join(map(str,ans)))


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int h,w,i,j,k,a[4][2];
	bool q;
	string t;
	vector<string> g;
    cin>>h>>w;
    for (i=0;i<h;i++){
    	cin>>t;
    	g.push_back(t);
    }
    for (i=0;i<h;i++){
    	q=true;
    	for (j=0;j<g[i].size();j++){
    		if (g[i][j]=='#'){
    			a[0][0]=i-1;a[0][1]=j;
    			a[1][0]=i+1;a[1][1]=j;
    			a[2][0]=i;a[2][1]=j+1;
    			a[3][0]=i;a[3][1]=j-1;
    			q=false; 
    			for (k=0;k<4;k++){
    				if (a[k][0]>=0&&a[k][1]>=0&&a[k][0]<h&&a[k][1]<w){
    					if (g[a[k][0]][a[k][1]]=='#'){
    						q=true;
    					}
    				}
    			}
    			if (q==false){
    				break;
    			}
    		}
    	}
    	if (q==false){
    		break;
    	}
    }
    if (q==false){
    	cout<<"No";
    }
    else {
    	cout<<"Yes";
    }
	return 0;
}

Measured memory_bytes: 256
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll N;
    cin >>N;
    string ans;
    while(N>0){
        ans= (char)('a' + (N-1)%26) +ans;
        if(N==26)break;
        N= (N-(N-1)%26) / 26;
    }

    cout << ans <<'\n';


    return (0);
}

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

int main() {
  string ABCD;
  cin >> ABCD;
  int A=ABCD.at(0)-'0', B=ABCD.at(1)-'0', C=ABCD.at(2)-'0', D=ABCD.at(3)-'0';
  if (A+B+C+D==7) cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  else if (A-B+C+D==7) cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  else if (A+B-C+D==7) cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  else if (A+B+C-D==7) cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  else if (A+B-C-D==7) cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  else if (A-B+C-D==7) cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  else if (A-B-C+D==7) cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
  else if (A-B-C-D==7) cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
}


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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int a,b,c;
  int sum=0;
  cin>>a;sum+=a;
  cin>>b;sum+=b;
  cin>>c;sum+=c;
  if(sum%2==0 && (a==sum/2 || b==sum/2 || c==sum/2))puts("Yes");
  else puts("No");

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

string s;

int main() {
    cin >> s;
    if (s.size() <= 2) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll cnt = 0;
    rep(i,(int)s.size()-1) {
        if (s[i] == 'A') cnt++;
        if (s[i] == 'B' && s[i+1] == 'C') {
            ans += cnt;
            i++;
        } else if (s[i] != 'A') {
            cnt = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))

dp_table=[]
for i in range(n):
    if i==0:dp_table.append(0)
    elif i==1:dp_table.append(abs(a[i]-a[i-1]))
    else:dp_table.append(min(abs(a[i]-a[i-2])+dp_table[-2],abs(a[i]-a[i-1])+dp_table[-1]))
print(dp_table[-1])

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[5];
    rep(i,5)cin>>a[i];
    rep(i,5){
      if(a[i]==0){
        cout<<i+1<<endl;
        break;
      }
    }

    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename F> long long discrete_binary_search(long long ok, long long ng, F is_ok) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (is_ok(mid) ? ok : ng) = mid;
    }
    return ok;
}

int N, K;
int A[220000];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> A[i]; }
    cout << discrete_binary_search(1e10, 0, [&](int x) {
        int cur = 0;
        rep(i, N) { cur += (A[i] - 1) / x; }
        return cur <= K;
    }) << endl;
}

Measured memory_bytes: 5060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

const double EPS = 1e-15;

struct Point {
	double x, y;

	bool operator < ( const Point & other ) const {
		if ( x != other.x ) return x < other.x;
		return y < other.y;
	}

	Point operator - ( const Point & other) {
		Point res;
		res.x = x - other.x;
		res.y = y - other.y;
		return res;
	}

	double norm() {
		return x * x + y * y;
	}
};


typedef vector<Point> Polygon;
typedef Point Vector;

double cross( Vector a, Vector b ) {
	return a.x * b.y - a.y * b.x;
}

double dot( Vector a, Vector b ) {
	return a.x * b.x + a.y * b.y;
}

bool comp( Point a, Point b ) {
	if ( a.y != b.y ) return a.y < b.y;
	return a.x < b. x;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
	if ( cross(a, b) < -EPS ) return CLOCKWISE;
	if ( dot(a, b) < -EPS ) return ONLINE_BACK;
	if ( a.norm() < b.norm() ) return ONLINE_FRONT;

	return ON_SEGMENT;
}

Polygon andrewScan( Polygon s ) {
	Polygon u, l;
	if ( s.size() < 3 ) return s;
	sort(s.begin(), s.end()); // 以x,y為基準升序排序

	// 將x值最小的2個點添加至u
	u.push_back(s[0]);
	u.push_back(s[1]);
	// 將x值最大的2個點添加至l
	l.push_back(s[s.size() - 1]);
	l.push_back(s[s.size() - 2]);

	// 構建凸包上部
	for ( int i = 2; i < s.size(); i++ ) {
		for (int n=u.size();n >= 2 && ccw(u[n-2], u[n-1], s[i]) >= 0; n--) {
			u.pop_back();
		}
		u.push_back(s[i]);
	}

	// 構建凸包下部
	for ( int i = s.size() - 3; i >= 0; i-- ) {
		for( int n=l.size();n >= 2 && ccw(l[n-2], l[n-1], s[i]) >= 0; n--) {
			l.pop_back();
		}
		l.push_back(s[i]);
	}

	// 按逆時針方向生成凸包的點的序列
	reverse(l.begin(), l.end());
	for ( int i = u.size() - 2; i >= 1; i-- ) l.push_back(u[i]);

	return l;
}

int main() {
	int n;
	Polygon s;
	
	scanf("%d", &n);
	for ( int i = 1;i<=n;i++)
	{
		Point x;
		scanf("%lf %lf", &x.x, &x.y);
		s.push_back(x);
	}
	s = andrewScan( s );

	printf("%d\n", s.size());

	int pos = -1;
	Point k;
	for ( int i = 0; i < s.size(); i++ ) {
		if( pos == -1 || comp(s[i], k) ) {
			pos = i;
			k = s[i];
		}
	}
	for ( int i = pos; i < s.size(); i++ ) {
		printf("%.0lf %.0lf\n", s[i].x, s[i].y);
	}
	for ( int i = 0; i < pos; i++) {
		printf("%.0lf %.0lf\n", s[i].x, s[i].y);
	}

	return 0;
}



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

int par(int u,int p[])
{
    return (p[u]==u)?u:(p[u]=par(p[u],p));
}

bool find(int u,int v,int p[])
{
 if(par(u,p)!=par(v,p)) return false;
 else return true;
}

void uni(int u,int v,int r[],int p[])
{
   if(r[par(u,p)]==r[par(v,p)])
   {
       p[par(v,p)]=par(u,p);
       r[u]++;
   }
   else if(r[par(u,p)]<r[par(v,p)])
   {
       p[par(u,p)]=par(v,p);
   }
   else
   {
       p[par(v,p)]=par(u,p);
   }
}


int main()
{
  int n,m,x,y,z,i;
  cin>>n>>m;
  int p[n+1],r[n+1],ans=0;
  for(i=0;i<=n;i++) {p[i]=i;r[i]=1;}
  while(m--)
  {
   cin>>x>>y>>z;
  if(find(x,y,p)==false)
  {
      uni(x,y,r,p);
  }
  }
  for(i=1;i<=n;i++)
  {
      if(p[i]==i) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
import itertools

n = int(input())
primes = [x for x in range(3, 55556, 2)]

for i in range(3, 237, 2):
    for j, p in enumerate(primes):
        if p <= i:
            continue
        if p % i == 0:
            primes[j] = 0
primes = [2] + [p for p in primes if p > 0]
aa = [p for p in primes if p <= 55555 and p % 5 == 1]
print(' '.join(map(str, aa[:n])))

Measured memory_bytes: 10076
N = int(input())
S = { 'AC':0, 'WA':0, 'TLE':0, 'RE':0 }
for n in range(N):
    S[str(input())] += 1

print('AC x',S['AC'])
print('WA x',S['WA'])
print('TLE x',S['TLE'])
print('RE x',S['RE'])

Measured memory_bytes: 9164
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
s = []

for i in range(m):
    s.append(list(map(int, input().split())))

p = list(map(int, input().split()))

ans = 0
for value in range(1 << n):
    all = True
    for i in range(m):
        count = 0
        for j in range(1, s[i][0] + 1):
            count += ((1 << (s[i][j] - 1)) & value) != 0
        if count % 2 != p[i]:
            all = False
            break
    if all:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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

	int N; cin >> N;
	vector<bool> v(N, false);

	int n = 0;
	for (int i = 0; i < N; i++) {
		char c; cin >> c;
		v[i] = (c == '1');
		if (v[i]) { n++; }
	}

	int x0 = n + 1;
	int x1 = n - 1;

	int res0 = 0, res1 = 0;
	vector<int> pow0(N, 0), pow1(N, 0);
	if (x0 >= 1) {
		res0 = 0;
		for (int i = 0; i < N; i++) {
			res0 *= 2;
			if (v[i]) res0++;
			res0 %= x0;
		}
		pow0[N - 1] = 1 % x0;
		for (int i = N - 2; i >= 0; i--) {
			pow0[i] = pow0[i+1] * 2;
			pow0[i] %= x0;
		}
	}
	if (x1 >= 1) {
		res1 = 0;
		for (int i = 0; i < N; i++) {
			res1 *= 2;
			if (v[i]) res1++;
			res1 %= x1;
		}
		pow1[N - 1] = 1 % x1;
		for (int i = N - 2; i >= 0; i--) {
			pow1[i] = pow1[i + 1] * 2;
			pow1[i] %= x1;
		}
	}

	for (int i = 0; i < N; i++) {
		if (v[i] == false) {// x0
			int temp = (res0 + pow0[i]) % x0;
			int ans = 1;
			int a = temp;
			while (a > 0) {
				int n = a;
				int b = 0;
				while (n > 0) {
					if (n % 2 == 1) { b++; }
					n /= 2;
				}
				ans++;
				a %= b;
			}
			cout << ans << endl;
		}
		else {// x1
			if (x1 == 0) { cout << 0 << endl; continue; }
			int temp = (res1 - pow1[i] + x1) % x1;
			int ans = 1;
			int a = temp;
			while (a > 0) {
				int n = a;
				int b = 0;
				while (n > 0) {
					if (n % 2 == 1) { b++; }
					n /= 2;
				}
				ans++;
				a %= b;
			}
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4356
#include<stdio.h>
int main(void)
{

	int a,b,c;

	int ax,bx,cx;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	if(a==5&&b==5&&c==7)
		printf("YES");
	else
		if(a==5&&b==7&&c==5)
			printf("YES");
		else	
			if(a==7&&b==5&&c==5)
				printf("YES");

			else
				printf("NO");

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    ll ans=1;
    vector<ll>t(n);
    rep(i,n){
        cin>>t[i];
        ans=ans/__gcd(ans,t[i])*t[i];
    }
    cout<<ans<<endl;
}

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

/* define const */

/* finish defineing const */

int a, b;

int main()
{
    cin >> a >> b;

    if (a == b)
    {
        cout << "Draw" << endl;
    }
    else if (a == 1)
    {
        cout << "Alice" << endl;
    }
    else if (b == 1)
    {
        cout << "Bob" << endl;
    }
    else
    {
        if (a < b)
        {
            cout << "Bob" << endl;
        }
        else
        {
            cout << "Alice" << endl;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ret = "No";
        for (String s : sc.next().split("")) {
            if (s.equals("7")) {
                ret = "Yes";
                break;
            }
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 35656
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())
s = input()

nummax = 0
for i in range(1, len(s)):
    s1 = s[0:i]
    s2 = s[i:]
    s1s = set()
    for j in s1:
        s1s.add(j)
    num = 0
    for j in s1s:
        if s2.count(j):
            num += 1
    nummax = max(nummax, num)

print(nummax)

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

#define ll long long
#define inf 0x3f3f3f3f
const int maxn=1e5+5;
#define mod 1000000007
/*int head[maxn],ver[maxn],nxt[maxn],tot,edge[maxn];
bool vis[maxn];
int d[maxn],ans;
void add(int x,int y)
{
    ver[++tot]=y;
    edge[tot]=1;
    nxt[tot]=head[x];
    head[x]=tot;
}
void dp(int x)
{
    vis[x]=1;
    for(int i=head[x];i;i=nxt[i])
    {
        int y=ver[i];
        if(vis[y])continue;
        dp(y);
        ans=max(ans,d[x]+d[y]+edge[i]);
        d[x]=max(d[x],d[y]+edge[i]);
    }
}*/

int main()
{
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
// G- lower.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;

const int N = 1e5;
int arr[N] , n;

int main()
{
	int n;
	bool smaller = true;
	cin >> n;

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

	int count = 0;
	int ans = 0;
	int j =  1;
	for (int i = 0; i < n - 1; i++) {
			if (arr[i] >= arr[j]) {
				count++;
			}
			else {
				ans = max(count, ans);
				count = 0;
			}
			j++;
	
	}
	ans = max(count, ans);
	cout << ans;

}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)
int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

int main(){
    int h, w;
    cin >> h >> w;
    char mat[h][w];
    int si, sj, gi, gj;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
            if(mat[i][j] == '@')    gi = i, gj = j;
            if(mat[i][j] == '%')    si = i, sj = j;
        }
    }
    vector<vector<int>> v(h, vector<int>(w, 1<<30));
    v[si][sj] = 0;
    queue<pair<int,int>> q;
    q.push({si,sj});
    int ans = 1<<30;
    while(!q.empty()){
        pair<int,int> p = q.front();    q.pop();
        int i = p.first, j = p.second;
        for(int k = 0; k < 4; k++){
            int ni = i+di[k], nj = j+dj[k];
            if(inRange(ni,0,h)&&inRange(nj,0,w)&&mat[ni][nj]!='#'&&v[ni][nj]==1<<30){
                v[ni][nj] = v[i][j]+1;
                if(mat[ni][nj] == '$')  ans = min(ans, v[ni][nj]);
                q.push({ni,nj});
            }
        }
    }
    cout << (v[gi][gj] < ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3308
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		
		int a;
		int b;
		String inputString;
		Scanner keyboard = new Scanner(System.in);
		
		inputString = keyboard.nextLine();
		
		Scanner input = new Scanner(inputString);
		
		a = input.nextInt();
		b = input.nextInt();
		
		if(a == b) System.out.println(a);
		else System.out.println(gcd(a, b));
		
	}
	
	public static int gcd(int a, int b) {
		
		int r = 1;
		int big = 0;
		int little = 0;
		
		if(a > b) {
			r = a % b;
			big = a;
			little = b;
		}
		else if(a < b) {
			r = b % a;
			big = a;
			little = b;
		}
		
		while(r != 0) {
			
			big = little;
			little = r;
			r = big % little;
			
		}
		
		return little;
	}

}



Measured memory_bytes: 26364
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int N;
vector<int> X,Y;
vector<pair<int,int> > pq;
map<pair<int,int>,int > mpq;

int main(void) {
    cin>>N;
    
    for(int i = 0;i < N;i++) {
        int x,y;
        cin>>x>>y;
        X.push_back(x);
        Y.push_back(y);
    }

    for(int i = 0;i < N;i++) {
        for(int j = i+1;j < N;j++) {
            pair<int,int> key1,key2;
            key1 = make_pair(X[i]-X[j],Y[i]-Y[j]);
            mpq[key1]++;
            key2 = make_pair(X[j]-X[i],Y[j]-Y[i]);
            if(key1.first == key2.first && key1.second == key2.second)
                continue;
            mpq[key2]++;
        }
    }
    if(N == 1) {
        cout<<1<<endl;

        return 0;
    }
    int ans = INT_MAX;
    for(auto v:mpq) {
        int diff = v.second;
        ans = min(ans,N-diff);
    }
    ans = ans == 0 ? 1 : ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<queue>
#include<vector> 
#include<cstdlib>
#include<algorithm>
#define N 10^9+5
using namespace std;
int main()
{
	char s1[3];
	scanf("%s",&s1);
	int max=0,s2=0;
	for(int i=0;i<3;i++)
	{
		if(s1[i]=='R') s2++;
		else
		{
			if(s2>=max) max=s2;
			s2=0;
		}
	}
	if(max<s2) max=s2;
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define FIO   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(NULL);
typedef long long ll;
int main(){
    FIO;
  ll n,c=0;
  cin>>n;
  int flag=1;
  for(ll i=1;i<n;i++)
  {
      for(ll j=1;j<n;j++)
      {
          if(i*j>n)
          {
              flag=0;
              break;
          }
          if(i*j<n)
          c++;
          
      }
     
  }
  cout<<c;

    return 0;

}

Measured memory_bytes: 3648
#import numpy as np
n = int(input())
a = list(map(int,input().split()))

thre = 10**18

a.sort(reverse=True)
#print(a)

flag = 0
tm = a[n-1]
if(tm==0):
  print(0)
else:
  tmp=a[0]
  for i in range(1,n):
    tmp*= a[i]
    if(tmp > thre):
      flag = 1
      break
  if(flag == 1):
    print(-1)
  else:
    print(tmp)

Measured memory_bytes: 84628
import java.util.Scanner;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = stdIn.nextInt();
        }

        int l = 1;
        int r = 0;
        for(int i=0; i<n; i++){
            if(a[i] > r)
                r = a[i];
        }


        while(l < r){
            int x = (l + r) / 2;
            if(isAbleToCut(a, x, k)){
                r = x;
            }else{
                l = x+1;
            }
        }

        System.out.println(l);
    }

    static boolean isAbleToCut(int[] a, int x, int k){
        int n = a.length;
        int cnt = 0;
        for(int i=0; i<n; i++){
            cnt += ((int)Math.ceil((double)a[i] / x)) - 1;
        }
        return cnt <= k;
    }
}

Measured memory_bytes: 59796
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

class BIT
    attr_accessor:bit,:n
    def initialize(n)
        @n=n
        @bit=array(@n+1,0)
    end

    def add(i,x)
      while i<=@n
          @bit[i]+=x
          i+=i&-i
      end
    end

    def sum(i)
        s=0
        while i>0
            s+=@bit[i]
            i-=i&-i
        end
        return s
    end
end

N=gets.to_i
A=get_i
exc={}
A.sort.each_with_index do|a_,i|
  exc[a_]=i+1
end
b=array(N)
N.times do|i|
    b[i]=exc[A[i]]
end
bit=BIT.new(N)
ans=0
b.each_with_index do|b_,i|
  ans+=i-bit.sum(b_) 
  bit.add(b_,1)
end
puts ans


Measured memory_bytes: 34388
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main() {
    int sum=0;
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        if(s[i]=='+')sum++;
        else sum--;
    }
    cout<<sum<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <climits>

const int MAXN = 200001;

int main()
{
    int K, N;
    std::cin >> K >> N;
    std::vector<int> A(N, 0);
    
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
    }
    
    int ans = K - A[N-1] + A[0];
    for (int i = 1; i < N; i++)
    {
        ans = std::max(ans, A[i] - A[i-1]);
    }

    std::cout << K - ans << std::endl;
    return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

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


int main(){
  int h, w;
  int hx, wx;
  cin >> h >> w >> hx >> wx;
  int res = h * w;
  cout << res - h*wx - w*hx + hx*wx << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

constexpr double EPS = 1e-9;

//???
class Point{
public:
    double x,y;
    Point (double x=0,double y=0) : x(x),y(y){}

    Point operator + (Point p){ return Point( x+p.x , y-p.y );}
    Point operator - (Point p){ return Point( x-p.x , y-p.y ); }
    Point operator * (double a){ return Point( a*x , a*y ); }
    Point operator / (double a){ return Point( x/a , y/a ); }

    double abs(){   //??§??????
        return sqrt(norm());
    }

    double norm(){  //?????????
        return x*x+y*y;
    }

    bool operator == (const Point &p) const{
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

using Vector = Point;

double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; }

void solve(Point p1,Point p2,Point p3,Point pin){

    //cout << p1.x << " " << p1.y << " " << p2.x << " " <<p2.y << " " <<p3.x << " " << p3.y << " " << pin.x << " " <<pin.y << endl;

    bool ok = true;
    Point p[3] = {p1,p2,p3};

    for(int i=0;i<3;i++){
        Vector v1 = Vector(p[(i+1)%3]-p[i]);
        Vector v2 = Vector(p[(i+2)%3]-p[i]);
        Vector vin = Vector(pin-p[i]);

        double c1 = cross(v1,vin);
        double c2 = cross(v1,v2);
        if(c1*c2 < -EPS) ok=false;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main(){
    while(true){
        double x1,x2,x3,xin,y1,y2,y3,yin;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xin >> yin;
        if(cin.eof()) break;
        solve(Point(x1,y1),Point(x2,y2),Point(x3,y3),Point(xin,yin));
    }
}

Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    char c;
    cin>>c;
    if(c=='A')cout<<"T"<<endl;
    if(c=='T')cout<<"A"<<endl;
    if(c=='C')cout<<"G"<<endl;
    if(c=='G')cout<<"C"<<endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a = N / 1000;
    int b = N % 1000 / 100;
    int c = N % 100 / 10;
    int d = N % 10;


    if ((a == b && b == c) || (b == c && c == d)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def knapsack(nums):
    n = len(nums)
    if n == 0 or n == 1:
        return 0

    if n == 2:
        return abs(nums[0] - nums[1])

    # dp[i] is min cost when reaching stone i
    dp = [0] * n
    dp[1] = abs(nums[0] - nums[1])
    for i in range(2, n):
        dp[i] = min(
            dp[i-1] + abs(nums[i-1] - nums[i]),
            dp[i-2] + abs(nums[i-2] - nums[i])
        )

    return dp[-1]


if __name__ == "__main__":
    _ = input()
    nums = [int(x) for x in input().split()]
    print(knapsack(nums))


Measured memory_bytes: 13772
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	s := next()
	sum := 0
	for i := 0; i < len(s); i++ {
		a, _ := strconv.Atoi(string(s[i]))
		sum += a
		sum %= 9
	}
	if sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

#define endl '\n'
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, j) for (int i = 0; i < j; i++)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

void solve() {
    int n, a = 0, b = 0, c = 0, d = 0;
    cin >> n;
    forn(i, n) {
        string s;
        cin >> s;
        if(s == "AC")
            a++;
        if(s == "WA")
            b++;
        if(s == "TLE")
            c++;
        if(s == "RE")
            d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return;
} 

int32_t main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,m;
  cin >> d >> m;
  if(m<100){
    cout << m;
    for(int i=0;i<d;i++){
      cout << "00";
    }
  }
  else{
    cout << 101;
    for(int i=0;i<d;i++){
      cout << "00";}}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
string str1,str2,str3;
cin>>str1 >>str2 >>str3;
if (str1[str1.length()-1]==str2[0]&&str2[str2.length()-1]==str3[0]){
	cout<<"YES"<<endl;
}
else{
	cout<<"NO"<<endl;
}
return 0;
}


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

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

    int A[n][26] = {};

    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.size(); j++){
            A[i][(int)s[j] - 'a']++;
        }
    }

    string ans = "";
    for(int i = 0; i < 26; i++){
        int tmp = 1e9;
        for(int j = 0; j < n; j++){
            tmp = min(tmp, A[j][i]);
        }
        for(int j = 0; j < tmp; j++){
            ans += 'a' + i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
x = list(map(int, input().split()))
res=[]

if x[0]+x[2]-1>=x[1]-x[2]:
    for i in range(x[0],x[1]+1):
        print(i)
    quit()

for i in range(x[0],x[0]+x[2]):
    res.append(i)
for i in range(x[1]-x[2]+1,x[1]+1):
    res.append(i)

for i in res:
    print(i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n, K, Q, a[2010], b[2010];
int dbg;
int f(int lo, int hi) {
	for(int i=1; i<=n; i++) {
		if(a[i] < lo) b[i] = 0;
		else if(a[i] <= hi) b[i] = 1;
		else b[i] = 2;
	}
	int tot = 0, cnt = 0, r = 0;
	for(int i=1; i<=n; i++) {
		if(b[i]) {
			tot++;
			if(b[i] == 1) cnt++;
			if(i == n || !b[i+1]) {
				if(tot < K) continue;
				r += min(tot - K + 1, cnt);
			}
		} else tot = cnt = 0;
	}
	//printf("lo:%d, hi:%d, r:%d\n", lo, hi, r);
	return r;
}
int main() {
	scanf("%d%d%d", &n, &K, &Q);
	for(int i=1; i<=n; i++) scanf("%d", a+i);
	int res = 1e9;
	for(int i=1; i<=n; i++) {
		int lo = a[i], hi = 1e9 + 10;
		while(lo < hi) {
			int mid = (lo + hi) / 2;
			if(f(a[i], mid) >= Q) hi = mid;
			else lo = mid + 1;
		}
		if(lo == 1e9 + 10) continue;
		//printf("a[i]:%d, lo:%d\n", a[i], lo);
		res = min(res, lo - a[i]);
	}
	printf("%d", res);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	V<int> v(n);

	int i;

	rep(i, n) cin >> v[i];

	sort(All(v));
	Unique(v);

	Out(v.size());
	
	return 0;
}


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

 int main() {
   int n, r;
   cin >> n >> r;
   int res;
   if (n > 9) {
     res = r;
   }else{
     res = 100* (10 - n) + r;
   }
   cout << res << '\n';
 }


Measured memory_bytes: 256