akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n ;
    vector<pair<pair<string,int>,int> > a(n) ;
    
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i).first.first >> a.at(i).first.second ;
        a.at(i).second = i+1 ;
        a.at(i).first.second *= -1 ;
    }
    sort(a.begin() , a.end()) ;
    for (size_t i = 0; i < n; i++)
    {
        /* code */
        cout << a.at(i).second << endl ;
    }
    
}

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

int main() {
  ll a,b;
  cin >> a >> b;
  ll n=a,m=b;
  map<ll,ll> res;
  for(ll i=2;i*i<=min(n,m);i++) {
    while(min(n,m)%i==0) {
      if(max(n,m)%i==0) {
        res[i]++;
        n/=i;
        m/=i;
      }
      else {
        if(min(n,m)==n) {
          n/=i;
        }
        else {
          m/=i;
        }
      }
    }
  }
  if(min(n,m)!=1) {
    if(max(m,n)%min(n,m)==0) res[min(n,m)]=1;
  }
  
  cout << res.size()+1 << endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

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

    vector<int> t;
    for (int i = 0; i < n; ++i) {
        t.push_back(i+1);
    }

    int pn = 0;
    int qn = 0;

    int num = 1;

    do {
        bool p_ok = true;
        bool q_ok = true;

        for (int i = 0; i < n; ++i) {
            if (t[i] != p[i]) {
                p_ok = false;
            }

            if (t[i] != q[i]) {
                q_ok = false;
            }
        }

        if (p_ok) {
            pn = num;
        }

        if (q_ok) {
            qn = num;
        }

        ++num;
    } while (next_permutation(t.begin(), t.end()));

    cout << abs(pn - qn) << endl;
}

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

#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;

int main(){
     int n;cin >> n;
     int a[n];rep{
             cin >> a[i];
     }
     string frag = "Yes";
     for(int i = n-1;i>0;i--){
             if(a[i-1] - a[i] == 1) a[i-1] -= 1;
             else if(a[i-1] - a[i] > 1 ) frag = "No";
     }     
     cout << frag << endl;
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int n;
vector<int> a;
vector<ll> dp;

ll solve(int i) {
	ll ans = dp[n];
	int idx1 = lower_bound(ALL(dp), dp[i + 1] / 2) - dp.begin() - 1;
	int idx2 = lower_bound(ALL(dp), dp[i + 1] + (dp[n] - dp[i + 1]) / 2) - dp.begin() - 1;

	const int r = 2;
	REPU(i1, idx1 - r, idx1 + r) REPU(i2, idx2 - r, idx2 + r) {
		if (i1 < 0 || i1 >= n || i2 < 0 || i2 >= n) continue;
		if (!(i1 < i && i < i2 && i2 < n - 1)) continue;
		ll x1 = dp[i1 + 1];
		ll x2 = dp[i + 1] - x1;
		ll x3 = dp[i2 + 1] - x1 - x2;
		ll x4 = dp[n] - x1 - x2 - x3;
		ll tmp = max(max(x1, x2), max(x3, x4)) - min(min(x1, x2), min(x3, x4));
		//DEBUG(i1, i, i2, tmp);
		amin(ans, tmp);
	}
	return ans;
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	cin >> n;
	a.resize(n);
	dp.resize(n + 1);
	dp[0] = 0;
	REPU(i, 0, n) {
		cin >> a[i];
		dp[i + 1] = dp[i] + a[i];
	}
	ll ans = dp[n];
	REPU(i, 1, n - 2) {
		amin(ans, solve(i));
	}
	cout << ans << endl;
	

	return 0;
}


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

using namespace std;

int G[555][555];

int f(int n, int s, int level) {
    for (int i = 0; i < n/2; ++i) {
        for (int j = n/2; j < n; ++j) {
            G[s+i][s+j] = level;
        }
    }
    if (n <= 2) return 1;
    return max(f(n/2, s, level+1), f(n-n/2, s+n/2, level+1)) + 1;
}

int main() {
    int n;
    cin >> n;
    int res = f(n, 0, 1);
    // cout << res << endl;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) cout << G[i][j] << " \n"[j==n-1];
    }
    return 0;
}


Measured memory_bytes: 1536
N,M,X,Y = map(int,input().split(" "))
list1 = list(map(int,input().split(" ")))
list2 = list(map(int,input().split(" ")))
list1.sort(reverse=True)
list2.sort()
while(True):
    if list1[0] >= Y:
        print("War")
        break
    if list2[0] <= X:
        print("War")
        break
    if list1[0] >= list2[0]:
        print("War")
        break
    elif list2[0] < Y:
        print("No War")
        break



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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	vector<string> s(N);
	REP(i,N) cin >> s[i];

	int last_a=0;
	int first_b = 0;
	int ba = 0;
	int ans = 0;
	REP(i,N){
		REP(j,s[i].length()-1){
			if(s[i].substr(j,2) == "AB") ans++;
		}
		if(s[i].back() == 'A' and s[i].front() == 'B') ba++;
		if(s[i].back() == 'A' and s[i].front() != 'B') last_a++;
		if(s[i].front() == 'B' and s[i].back() != 'A') first_b++;
	}
	if(last_a == 0 and first_b == 0 and ba > 0) ans += ba-1;
	else ans += min(last_a+ba, first_b+ba);
	cout << ans << endl;


	return 0;

}


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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

const int N = 10 + 1, INF = 1e9;
PII Group[N];
int Tab[N];
int n;
LL m;

int main()
{   
    scanf("%d %lld", &n, &m);
    
    for (int i = 0; i < n; ++i)
        scanf("%d %d", &Group[i].st, &Group[i].nd);

    for (int i = 0; i < n; ++i)
        Tab[i] = i;

    int result = INF;

    do 
    {
        LL sum = 0LL;
        int cnt = 0;

        for (int i = 0; i < n && sum < m; ++i)
        {
            LL rem = m - sum;
            LL score = 100LL * (LL)(Tab[i] + 1);
            LL need = rem / score;
            if (rem % score != 0LL)
                ++need;

            LL mini = min(need, (LL)Group[Tab[i]].st);

            sum += mini * score;
            if (mini == (LL)Group[Tab[i]].st)
                sum += (LL)Group[Tab[i]].nd;

            cnt += (int)mini;
        }

        result = min(result, cnt);

    } while (next_permutation(Tab, Tab + n));

    printf("%d", result);

    return 0;
}

Measured memory_bytes: 256
// E - Multiplication 4
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int vpop(vector<int>& v){int x=v.back();v.pop_back();return x;}

int main(){
	int N, K; cin>>N>>K;
	vector<int> P, M, A;
	rep(i, N){
		int a; cin>>a;
		A.push_back(a);
		if(a < 0) M.push_back(a);
		else P.push_back(a);
	}

	sort(P.begin(), P.end());
	sort(M.rbegin(), M.rend());

	vector<int> p, m;
	while(int(p.size() + m.size()) < K){
		if(P.size() > 0 && M.size() <= 0) p.push_back(vpop(P));
		else if(P.size() <= 0 && M.size() > 0) m.push_back(vpop(M));
		else if(P.back() < -M.back()) m.push_back(vpop(M));
		else p.push_back(vpop(P));
	}

	if(m.size()%2){
		int mi, pi;
		mi = (p.size() * M.size() == 0)? 1: vpop(M);
		pi = (m.size() * P.size() == 0)? -1: vpop(P);
		if(mi < 0 && pi >=0){
			if(abs((int64_t)p.back() * pi) < abs((int64_t)m.back() * mi)){ p.pop_back(); m.push_back(mi); }
			else{ m.pop_back(); p.push_back(pi); }
		}
		else if (mi < 0){ p.pop_back(); m.push_back(mi); }
		else if (pi >= 0){ m.pop_back(); p.push_back(pi); }
		else{
			sort(A.begin(), A.end(), [](int x, int y){ return abs(x) < abs(y); });
			p.clear(); m.clear();
			rep(i, K) p.push_back(A[i]);
		}
	}

	int64_t ans = 1;
	int mod = 1'000'000'007;
	for(int a:p) ans = ans * a % mod;
	for(int a:m) ans = ans * a % mod;
	cout<< (ans+mod)%mod <<endl;
}


Measured memory_bytes: 7096
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long n = sc.nextLong();
        ArrayList<Long> li = getPrimeList(n);
        long ans = 0;
        for(long v : li){
            long div = n/v-1;
            if(n%div == v){
                ans += div;
            }
        }
        System.out.println(ans);
    }
    
    private static ArrayList<Long> getPrimeList(long l){
        ArrayList<Long> ret = new ArrayList<Long>();
        long max = (long)Math.ceil(Math.sqrt(l));
        for(long i = 1; i < max; i++){
            if(l%i==0) ret.add(i);
        }
        return ret;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N = 5e5 + 50, P = 998244353; 

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
void upd(int &a,int b) { a=add(a,b); } 
int powMod(int a, int k) {
	int res = 1; 
	for (;k;k >>= 1, a = mul(a, a)) if (k & 1) res = mul(res, a); 
	return res;
}

int n, m, ans, fac[N], inv[N]; 
int Comb(int n, int m) {
	if (n < 0 || m > n) return 0; 
	return mul(fac[n], mul(inv[m], inv[n - m])); 
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in", "r", stdin); 
#endif
	fac[0] = 1; lop(i, 1, N) fac[i] = mul(fac[i - 1], i); 
	inv[1] = 1; lop(i, 2, N) inv[i] = mul(P - P / i, inv[P % i]); 
	inv[0] = 1; lop(i, 1, N) inv[i] = mul(inv[i - 1], inv[i]); 
	cin >> n >> m; 
	int flag = 1;
	rep(p, 0, min(n, m)) {
		upd(ans, mul(flag, mul(fac[p], mul(mul(Comb(n, p), powMod(m + 1, n - p)), mul(Comb(m, p), powMod(n + 1, m - p)))))); 
	//	Pr("p = %d, coefficient = %d\n", p,  mul(mul(Comb(n, p), powMod(m + 1, n - p)), mul(Comb(m, p), powMod(n + 1, m - p))));
		flag = flag == 1 ? P - 1 : 1;
	}
	cout << ans << endl;
	return 0; 
}




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

int N, M, X;
vector<int> C(15, 0);
vector<vector<int>> A(15, vector<int>(15, 0));
int res = 12345678;

int main(){
  cin >> N >> M >> X;

  for(int i = 0; i < N; i++){
    cin >> C[i];
    for(int j = 0; j < M; j++) cin >> A[i][j];
  }

  int n = (1 << N);
  for(int i = 0; i < n; i++){
    int sum = 0;
    vector<int> U_val(15, 0);
    for(int s = 0; s < N; s++){  //shift
      int m = (i >> s);
      if(m & 1){
        for(int j = 0; j < M; j++) U_val[j] += A[s][j];
        sum += C[s];  //s番目をとるので金額追加
      }
    }

    //for(int k = 0; k < M; k++) cout << U_val[k] << endl;
      
    bool ok = true;
    for(int k = 0; k < M; k++){
      if(U_val[k] < X){ ok = false; break; }
    }

    if(ok) res = min(res, sum);
  }

  if(res == 12345678) cout << -1 << endl;
  else cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int H, W;
	string S[26][26];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == "snuke") {
				printf("%c%d", j+'A', i + 1);
				break;
			}
		}
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<vector>

using namespace std;

vector<int> vec[101];
bool ch[101]={};
bool visited[101]={};
int dp[101]={};
stack<int> st;
int maxx = -1;
int maxNODE = -1;


void DFS(int i,int val){
    if(val > maxx)maxx = val;
    dp[i] = max(dp[i],val);
    //printf("%d ",i);
    for (int k=0; k<vec[i].size(); k++) {
        if(!ch[vec[i][k]]){
            visited[vec[i][k]] = true;
            ch[vec[i][k]] = true;
            DFS(vec[i][k],val+1);
            ch[vec[i][k]] = false;
        }
    }
}

int main(){
    maxx = -1;
    maxNODE = -1;
    int n,a,b;
    scanf("%d",&n);
    if(n == 0)return 0;
    for (int i=0; i<n; i++) {
        scanf("%d %d",&a,&b);
        vec[a].push_back(b);
        vec[b].push_back(a);
        if(a>b)if(maxNODE < a)maxNODE = a;
        if(a<b)if(maxNODE < b)maxNODE = b;
    }
    for (int i=1; i<=maxNODE; i++) {
        visited[i] = true;
        ch[i] = true;
        DFS(i,1);
        ch[i] = false;
    }
    for (int i=1; i<=maxNODE; i++) {
        if(maxx == dp[i]){
            ch[i] = true;
            DFS(i,1);
            ch[i] = false;
            break;
        }
    }
    printf("%d\n",maxx);
    for (int i=1; i<=maxNODE; i++) {
        visited[i] = false;
        vec[i].clear();
    }
    main();
    
    
}

Measured memory_bytes: 2620
#include <iostream>
#include <string>

using namespace std;

int main(){

    int n;
    cin >> n;

    float sum = 0.0;

    for(int i = 0; i < n; i++){
        float x;
        string u;
        cin >> x >> u;

        if(u == "JPY"){
            sum = sum + x;
        }else{
            sum = sum + x * 380000;
        }


    }

    cout << sum << endl;

    return 0;
}

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

char buf[100100];
int nxt[30][100100];
string s, t;
string s2;
int n, m;

int main(){
	scanf("%s", buf); s = buf; n = s.size();
	s2 = s + s;
	scanf("%s", buf); t = buf; m = t.size();
	rep(num, 26){
		char now = num + 'a';
		bool has = 0, need = 0;
		rep(i, n) has |= (s[i] == now);
		rep(i, m) need |= (t[i] == now);
		if(need && !has){
			cout << "-1" << endl;
			return 0;
		}
		if(!has) continue;
		rep(i, n){
			if(s2[n + i] == now){
				nxt[num][i] = i;
				for(int j = n + i - 1; s2[j] != now; j--){
					nxt[num][j % n] = i;
				}
			}
		}
	}
	long long num = 0ll, ans = 0ll;
	int pos = -1;
	rep(i, m){
		int to = nxt[t[i] - 'a'][(pos + 1) % n];
		if(to <= pos) num++;
		pos = to;
		ans = to;
	}
	cout << n*num + ans+1 << endl;
	return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int d;
int main(){
    cin>>d;
    d-=25;
    cout<<"Christmas";
    for(int i=-1;i>=d;i--){
        cout<<" Eve";
    }
    cout<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


// 2011/10/21

//@2101@®S 
public class Main {

	// föªð·é
	//  zñÉfÆA×«ªðÝÉÀÔ
	//  0 ÆÍnullðÔ·
	//  1 ÌÆ«ÍózñðÔ·
	long[] soinsubunkai(long a) {
		if (a <= 0)
			return null;
		List<Long> list = new ArrayList<Long>();
		if (a % 2 == 0) {
			a /= 2;
			int beki = 1;
			while(a % 2 == 0) {
				a /= 2;
				beki++;
			}
			list.add(2L);
			list.add((long)beki);
		}
		for(long k = 3;; k += 2) {
			if (k * k > a)
				break;
			if (a % k == 0) {
				a /= k;
				int beki = 1;
				while(a % k == 0) {
					a /= k;
					beki++;
				}
				list.add(k);
				list.add((long)beki);
			}
		}
		if (a != 1) {
			list.add(a);
			list.add(1L);
		}
		
		long[] ret = new long[list.size()];
		for(int i = 0; i < list.size(); i++) {
			ret[i] = list.get(i);
		}
		return ret;
	}

	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int[] ir = readIntArray();
		
		int n = ir[0];
		if (n == 0)
			return false;
		
		long[] so = soinsubunkai(n);

		long mul = 1;
		for(int i = 0; i < so.length / 2; i++) {
			long a = so[i * 2];
			long b = so[i * 2 + 1];
			long sum = 1;
			long m = 1;
			for(int j = 0; j < b; j++) {
				m *= a;
				sum += m;
			}
			mul *= sum;
		}
		
		String s;
		if (mul > n * 2) {
			s = "abundant number";
		}
		else if (mul == n * 2) {
			s = "perfect number";
		}
		else  {
			s = "deficient number";
		}
		
		// ðÌ\¦
		System.out.printf("%s\n", s);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
//			String inputStr = "1,2 4,";
			String inputStr = "28,0,";

			inputStr = inputStr.replace(",", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = readIntArray()[0];

		for(int i = 0; /*i < N*/; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌXy[XæØèÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		if (s == null)
			return null;
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 12000
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

int n, m;
vector <int> adj[1001];
bool visited[1001];
int trace[1001];

void dfs(int now, int start)
{
	for (auto next : adj[now])
	{
		if (visited[next] == false)
		{
			visited[next] = true;
			trace[next] = now;
			dfs(next, start);
		}
		else
		{
			vector <int> v;
			if (next == start)
			{
				int x = now;
				bool check[1001];
				memset(check, false, sizeof(check));
				while (1)
				{
					if (x == -1)
					{
						break;
					}
					v.push_back(x);
					check[x] = true;
					x = trace[x];
				}

				int indegree[1001] = { 0, };
				int outdegree[1001] = { 0, };
				for (int i=0;i<v.size();i++)
				{
					for (auto it : adj[v[i]])
					{
						if (check[it] == true)
						{
							outdegree[v[i]]++;
							indegree[it]++;
						}
					}
				}

				for (auto it : v)
				{
					if (indegree[it] > 1 || outdegree[it] > 1)
					{
						return;
					}
				}

				cout << v.size() << '\n';
				for (auto it : v)
				{
					cout << it << '\n';
				}

				exit(0);
			}
		}
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
	}

	for (int i = 1; i <= n; i++)
	{
		memset(visited, false, sizeof(visited));
		memset(trace, -1, sizeof(trace));
		visited[i] = true;
		dfs(i,i);
	}
	cout << -1 << '\n';
	return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize "03"
#pragma GCC target("sse4")

#define ll long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FRE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define f(i,n) for(ll i=0;i<n;i++)
#define fa(i,a,n) for(ll i=a;a<n?i<n:i>=n;a<n?i+=1:i-=1)
#define loop(i,a, n) for(ll i = a; i <= n; i++)
#define loopb(i,a, n) for(ll i = a; i >= n; i--)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define setmem(x, k) memset(x, k, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define MOD 1000000007
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
// const ll N = 1e6+5;	
// ll a[N], b[N], dp[N], in[N], out[N], level[N], vis[N];
// vl g[N];
ll n, m;

const ll INF = 1e9 + 5;
vector<ll> a;
void solve() {
	// ll k, x, y, p, q, r;
	cin>>n;
	a.resize(n);
	f(i,n) cin >> a[i];
	vector<ll> dp(n, INF);
	dp[0] = 0;
	f(i,n){
		for(ll j: {i+1, i+2}){
			if(j < n) {
				dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
			}
		}
	}
	cout << dp[n-1];
}

int32_t main() {
	IOS
	ll T;
	// cin >> T;
	// while(T--)
		solve();
	cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Problem Specific Parameter:


ll ans = 0LL;
const ll mod = 1000000007LL;

ll power(ll a, ll n) {
	ll b = 1LL;
	while (n) {
		if (n & 1) b = b * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return b;
}

void cnt(int n, int num) {
	const int d = n / num;
	const ll all = 9LL * power(10LL, d - 1) % mod;
	ans = (ans + all  - num) % mod;
}

const int limit = 23000000;
ll f[limit + 1];

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

	ans = n / 8;
	// num
	for (int i = 1; i * i <= n; ++i) {
		if (n % i) continue;
		if (i <= n / 8) cnt(n, i);
		if (i * i == n) continue;
		if (n / i <= n / 8 ) cnt(n, n / i);
	}

	//cout << ans << endl;

	ll add = 0LL, thr = 1LL;
	rep(i, 1, limit + 1) {
		if (i == thr) add++, thr *= 10LL;
		f[i] = add;
	}

	int lft = 1, rht = 1, cur = 0;
	while (f[lft] <= 7) {
		while (rht < limit and cur < n) cur += f[rht++];
		if (cur == n) ans++;
		cur -= f[lft++];
	}

	ans %= mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 179968
#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <fstream>
#define MAXSIZE 100010
#define MAXN 10
#define MAXND MAXN / 10
#define INF 99999999
#define MAXEDGE 1000000
#define MAXVERTEX 510
#define EPS 0.00001
#define PI 3.14159265
#define MOD 1000000009
#define nil NULL
typedef long long ll;
using namespace std;

int main() {
    int a, b, c, d;
    
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) {
        printf("Yes");
    } else if (abs(a - b) <= d && abs(b - c) <= d) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}


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

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
}; 

int main(){
    Stream io;
    
    int N;
    io.read(N);
    auto prime_factor = [&](int n){
        map<int, int> primes;
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0){
                while(n % i == 0) {
                    n /= i;
                    primes[i]++;
                }
            }
        }
        if(n > 1) primes[n]++;
        return primes;
    };
    int ans = 0;
    for(int i = 2; i <= N; i++){
        if(i % 2 == 0) continue;
        auto primes = prime_factor(i);
        int prd = 1;
        for(auto itr = primes.begin(); itr != primes.end(); itr++){
            prd *= itr->second + 1;
        }
        if(prd == 8) ans++;
    }
    cout << ans;
    return 0;
}

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

int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;
	if (a < 3200)cout << "red" << endl;
	else cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> to[200010];
ll d[200010]={};
void dfs(int i,int par){
    for(auto x:to[i]){
        if(x!=par){
            d[x]+=d[i];
            dfs(x,i);
        }
    }
}
int main(void){
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p,x;
        cin>>p>>x;
        d[p]+=x;
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++) cout<<d[i]<<" ";
}

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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    int c;
    num = 0;
    c = getchar();
    // bool negative = false;
    // if (c == '-') {
    // 	negative = true;
    // 	c = getchar();
    // }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    // if (negative)
    //     number = -number;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    int i = 0;
    ll base = 100;
    while (base < x) {
        base = base + base * 0.01;
        i++;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
ll n;
string s;
set<string> se;
int main(){
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> s;
		se.insert(s);
	}
	cout << se.size() << endl;
	return 0;
}


Measured memory_bytes: 19176
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

signed main(void)
{
    string n;
    cin >> n;
    
    rep(i, 3) {
        if (n[i] == n[i+1]) {
            mes("Bad");
            re0;
        }
    }
    mes("Good");
    
    
    
    
    
    
}

Measured memory_bytes: 3608
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, readline().split())
ans = 0
for i in range(N + 1):
    s = 0
    t = i
    while t:
        s += t % 10
        t = t // 10

    if A <= s <= B:
        ans += i
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int x;
  	
  	scanf("%d",&x);
  	x%=100;
  	x%=10;
  	
  	switch(x){
      case 2 :
      case 4:
      case 5:
      case 7:
      case 9:
        printf("hon\n");
        break;
      case 0 :
      case 1:
      case 6:
      case 8:
        printf("pon\n");
        break;
      default:
        printf("bon\n");
    }
  return 0;
}


Measured memory_bytes: 1636
#include "bits/stdc++.h"
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=100005;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

queue<int> q;
set<int> st;

int main()
{
    //read("in.txt"),write("out.txt");
    int n,cnt=0;
    ini(n);
    q.push(3);
    q.push(5);
    q.push(7);
    while(q.front()<=n)
    {
        int p=q.front();
        q.pop();
        if(st.find(p)==st.end())
        {
            st.insert(p);
            int x=p,d3=0,d5=0,d7=0;
            while(x)
            {
                int l=x%10;
                d3+=(l==3);
                d5+=(l==5);
                d7+=(l==7);
                x/=10;
            }
            if(d3&&d5&&d7)
                cnt++;
            q.push(p*10+3);
            q.push(p*10+5);
            q.push(p*10+7);
        }
    }
    outi(cnt),nl;
    return 0;
}


Measured memory_bytes: 2944
k,x=map(int,input().split())
#p_3,p_4=map(int,input().split())
#n=int(input())
#m=int(input())
#r=[int(input()) for _ in range(n)]
#o=list(map(int,input().split()))
#b=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#a=[list(map(int,input().split()))for _ in range(n)]
#a=list(input().split("+"))
#m=[list(input().split())for _ in range(n)]
ans=[]
for i in range(x-(k-1),x+k):
    ans.append(i)
print(*ans)


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


int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ma = LONG_MIN;
    ma = max(ma, a * c);
    ma = max(ma, b * c);
    ma = max(ma, b * d);
    ma = max(ma, a * d);
    cout << ma << "\n";
}

Measured memory_bytes: 3628
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
# Rはループさせるのでソートさせる必要ない
R = [getList() for i in range(N)]
R_l = [1] * N

B = [getList() for i in range(N)]
B.sort()

# 貪欲法でペア作りする問題
# ABC005 C - おいしいたこ焼きの売り方の時と同様に
# それとしか繋げないもの　を優先的に繋いでいく

# 条件Aの通過が厳しい順に対象bをソートし、
# たこ焼き　条件A:客が来る前にたこ焼きができてないといけない
#  　　　　      客を来るのが早い順に並べる（最初から並んでる）
# 今回     条件A:赤星のx座標が青星のx座標より小さくないといけない
#  　　　　　　　 青星をx座標が小さい順に並べる

# 条件A, 条件Bをクリアしたものの中で、最も条件Bの通過が厳しい対象aと結ぶ
# たこ焼き　条件B:たこ焼きが賞味期限より前のものでないといけない
#  　　　　      できるだけ古いものを売る（最初から並んでる）
# 今回     条件B:赤星のx座標が青星のy座標より小さくないといけない
#  　　　　　　　 条件をクリアしたもののうちでできるだけy座標が大きいものを選ぶ

ans = 0
for b in B:
    max_y = -1
    max_index = -1
    for i, a in enumerate(R):
        # x, y座標が小さいもののうちてまた使ってないもの
        if a[0] < b[0] and a[1] < b[1] and R_l[i] == 1:
            # あるならY座標が最も大きいもの
            if a[1] > max_y:
                max_y = a[1]
                max_index = i
    if max_y >= 0:
        R_l[max_index] = 0
        ans += 1
print(ans)

Measured memory_bytes: 83852
import sys
x1, y1, x2, y2 = map(int, sys.stdin.readline().split())

dx = x2 - x1
dy = y2 - y1

dx1, dy1 = -dy, dx
dx2, dy2 = -dy1, dx1

print(x2+dx1, y2+dy1, x2+dx1+dx2, y2+dy1+dy2)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
  int k, n, a[200000]={0};
  int b[200000]={0}, i;
  int b_max=0, ans=0;
  scanf("%d %d", &k ,&n);
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  for(i=0; i<n-1; i++){
    b[i] = a[i+1] - a[i];
  }
  b[n-1] = k - a[n-1] + a[0];
  for(i=0; i<n; i++){
    if(b_max < b[i]){
      b_max = b[i];
    }
    ans += b[i];
  }
  ans -= b_max;
  printf("%d\n", ans);
  return 0;
}


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

int main(){
  int n;
  string s;
  map<char, ll> mp;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') mp[s[0]]++;
  }
  ll num[] = {mp['M'], mp['A'], mp['R'], mp['C'], mp['H']};
  ll res = 0;
  for(int i = 0; i < 5; i++){
    for(int j = i + 1; j < 5; j++){
      for(int k = j + 1; k < 5; k++){
        res += num[i] * num[j] * num[k];
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
	long long n;cin>>n;
	long long p;cin>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	if(n>=40){
		cout<<1<<endl;
		return 0;
	}
	long long ans=1;
	long long i=1;
	while(1){
		long long pi=1;
		int flag=1;
		for(int j=0;j<n;j++){
			pi*=i;
			if(pi>p){
				flag=0;
				break;
			}
		}
		if(flag==0)break;
		if(p%pi==0)ans=i;
		i++;
//		cout<<i<<' '<<pi<<endl;
	}
	cout<<ans<<endl;
//	int ans=1;
//	vector<int> pf,pf2;
//	int i=1;
//	while(i*i<=p){
//		if(p%i==0){
//			pf.push_back(i);
//			pf2.push_back(p/i);
//		}
//		i++;
//	}
//	for(int i=0;i<pf.size();i++){
//		cout<<pf[i]<<' ';
//	}
//	for(int i=0;i<pf.size();i++){
//		if(pf[i]>=n){
//			ans=p/pf[i];
//			cout<<ans<<endl;
//			return 0;
//		}
//	}
//	for(int i=pf2.size()-1;i>=0;i--){
//		if(pf2[i]>n){
//			ans=p/pf2[i];
//			cout<<ans<<endl;
//			return 0;
//		}
//
//	}

	return 0;
}


Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

a = (1..h).map { gets.chomp.split("") }

stack = [[0, 0]]
reached = {[0, 0] => 1}

until stack.empty?
    y, x = stack.pop
    v = [y+1, x]
    if y < h-1 && !reached[v] && a[y+1][x] == ?#
        stack << v
        reached[v] = 1
    end
    v = [y, x+1]
    if x < w-1 && !reached[v] && a[y][x+1] == ?#
        stack << v
        reached[v] = 1
    end
end


if !reached[[h-1, w-1]]
    puts 'Impossible'
    exit
end

(0..h-2).each do |y|
    (0..w-2).each do |x|
        if a[y+1][x] == ?# && a[y][x+1] == ?#
            puts 'Impossible'
            exit
        end
    end
end

puts 'Possible'

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) { cin >> L[i]; }
  sort(all(L));
  int ans = 0;
  FOR(i, 0, N - 2) {
    FOR(j, i + 1, N - 1) {
      int lh = j + 1, rh = N - 1;
      if (L[i] + L[j] <= L[lh]) continue;
      if (L[i] + L[j] > L[rh]) {
        ans += rh - j;
        continue;
      }
      while (rh - lh > 1) {
        int mid = (rh + lh) / 2;
        if (L[i] + L[j] > L[mid]) {
          lh = mid;
        } else {
          rh = mid;
        }
      }
      ans += (lh - j);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>BIT;
ll sumUp(int a) {
  ll ret = 0;
  while (a) {
    ret += BIT[a];
    a -= a & -a;
  }
  return ret;
}
void add(ll n, int v, int N) {
  while (v <= N) {
    BIT[v] += n;
    v += v & -v;
  }
}
int main () {
  int N;
  cin >> N;
  BIT.assign(200002, 0);
  vector<int>P(N + 2);
  vector<int>F(N + 2);
  for (int i = 2; i <= N + 1; i ++) {
    cin >> P[i];
    F[P[i]] = i;
  }
  add(1, F[N], N + 2);
  add(1, 1, N + 2);
  add(1, N + 2, N + 2);
  ll ans = 0;
  for (int i = N - 1; i >= 1; i --) {
    int mi = F[i];
    int ma = N + 2;
    ll ke = sumUp(F[i]);
    while (ma != mi) {
      int mu = (ma + mi) / 2;
      if (sumUp(mu) < ke + 1) mi = mu + 1;
      else ma = mu;
    }
    ll R1 = (ll)mi;
    ma = N + 2;
    ll R2 = (ll)N + 2;
    if ((int)R1 != N + 2) {
      ke ++;
      while (ma != mi) {
        int mu = (ma + mi) / 2;
        if (sumUp(mu) < ke + 1) mi = mu + 1;
        else ma = mu;
      }
      R2 = (ll)mi;
      ke --;
    }
    mi = 1;
    ma = F[i];
    while (ma != mi) {
      int mu = (ma + mi) / 2;
      if (sumUp(mu) < ke) mi = mu + 1;
      else ma = mu;
    }
    ll L1 = (ll)ma;
    ll L2 = 1;
    if (L1 > 1) {
      mi = 1;
      ke --;
      while (ma != mi) {
        int mu = (ma + mi) / 2;
        if (sumUp(mu) < ke) mi = mu + 1;
        else ma = mu;
      }
      L2 = (ll)mi;
    }
    ll kj = (ll)F[i];
    //cout << i << ' ' << L1 << ' ' << L2 << ' ' << R1 << ' ' << R2 << endl;
    ans += (ll)((R1 - kj) * (L1 - L2) + (R2 - R1) * (kj - L1)) * i;
    add(1, kj, N + 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
   	int flag=1;
    for(int i=0;i<s.size();++i){
    	for(int j=i+1;j<s.size();++j){
    		if(s[i]==s[j]){
    			flag=0;
    			break;
    		}
    	}
    }
    cout<<((flag)?"yes":"no");
    return 0;
}


Measured memory_bytes: 3604
/***************
*
*   Eostrix......
*
****************/
#include<bits/stdc++.h>
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define pf printf
#define sc scanf
#define ll long long
#define gap " "
#define endl "\n"
#define maxSize 100000000
using namespace std;
const double pi = acos(-1.0);
void FILE_IO() {
	IN;
	OUT;
}
void faster_IO() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
}
int main()
{
	 faster_IO();
	///FILE_IO();
	double r;
	cin>>r;
	cout<<r*r<<endl;
    return 0;
}





Measured memory_bytes: 256