akhauriyash/Code-Regression huggingface dataset:
// Contest: AtCoder Beginner Contest 151 (https://atcoder.jp/contests/abc151)
// Problem: A: Next Alphabet (https://atcoder.jp/contests/abc151/tasks/abc151_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cpp_lib_nonmember_container_access >= 201411
#   define sz(x) ((int)size(x))
#else
#   define sz(x) ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define all(a)         (a).begin(),(a).end()
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __has_cpp_attribute(maybe_unused) >= 201603
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18;
//endregion }}}

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

    char c; cin >> c;
    cout << (char)(c + 1) << '\n';

    return 0;
}

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

typedef long long ll;
using namespace std;

const int MAX = 1e7;
const int MOD = 1e9 + 7;

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

ll com(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    com_init();
    ll x, y; cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    if (x < 0 || y < 0 || y > 2 * x || y < x / 2) {
        cout << 0 << endl;
        return 0;
    }
    ll n = (x + y) / 3;
    ll an = min(x - n, y - n);
    cout << com(n, an) << endl;
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int l; std::cin >> l;
  double a = l / 3.0;
  std::cout << a * a * a << "\n";
}


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

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 1; i < 10; i++){
    if (n%i == 0 && n/i < 10){
      cout << "Yes" << endl;
      count++;
      break;
    }
  }
  if (count == 0){
    cout << "No" << endl;
  }
}


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

int main() {
	int n; cin >> n;
	map<int, int>a;
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp; a[tmp]++;
	}
	int ans = a.size();
	cout << (a.size() % 2 == 0 ? ans - 1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 4992
n=int(input())
z=input()
s=list(z)
n=n%26
a=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
x=int(len(s))
d=[]
for i in range(x):
    b=s.pop(0)
    y=a.index(b)
    if y+n>25:
        c=y+n-26
    else:
        c=y+n
    d.append(a[c])
v=int(0)
ans=''.join(d)   
print(ans)

Measured memory_bytes: 3188
dbflag=0
def debug(*args):
  if dbflag: print(*args)

result = 0


N, K = map(int, input().split())

#リスト型
A = [int(i) for i in input().split(' ')]

bag = {}

for x in A:
	if 'x'+str(x) in bag:
		bag['x'+str(x)]+=1
	else:
		bag['x'+str(x)] = 1

debug(bag)
L = sorted(bag.items(),key= lambda x:x[1])
debug(L,len(L),K)
cnt = len(L) - K

if cnt > 0:
	result = sum(y[1] for y in L[0:cnt])
	debug([y[1] for y in L[0:cnt]])
else:
	result = 0


print(result)


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

string sed(string s, string a, string b){

    string res;
    int S = (int)s.size();
    int A = (int)a.size();
    int B = (int)b.size();

    for(int i = 0; i < S; i++){
        if(i + A > S){
            res += s[i];
            continue;
        }
        bool flag = true;
        for(int j = i; j < i + A; j++){
            if(s[j] != a[j - i]){
                flag = false;
                break;
            }
        }
        if(flag){
            res += b;
            i += A - 1;
        }else{
            res += s[i];
        }
    }
    return res;
}

int main(){

    while(1){

        int n; cin >> n;
        if(!n) break;
        vector<string> a(n);
        vector<string> b(n);
        for(int i = 0; i < n; i++){
            cin >> a[i] >> b[i];
        }
        string s, t; cin >> s >> t;

        set<string> Set;
        Set.insert(s);
        queue<pair<string, int> > q;
        q.push({s, 0});
        
        bool flag = false;

        while(!q.empty()){

            string tmp = q.front().first;
            int cost = q.front().second;
            //cout << tmp << endl;
            q.pop();

            if(tmp == t){
                cout << cost << endl;
                flag = true;
                break;
            }else if(tmp.size() >= t.size()) continue;

            for(int i = 0; i < n; i++){
                string next = sed(tmp, a[i], b[i]);
               // cout << i << " " << next << endl;
                if(Set.find(next) == Set.end() && next.size() <= t.size()){
                    Set.insert(next);
                    q.push({next, cost + 1});
                }
            }
        }
        
        if(!flag){
            cout << -1 << endl;
        }
    }
    return 0;
}


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

int main() {
  int N,A,a;
  cin >> N >> A;
  
  a = N % 500;
  
  if (A >= a) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const long long int MOD = 1000000007; 


int main() {
    string s;
    int d, lim;
    cin >> s;
    cin >> d;

    int length = s.size()+1;
    long long int dp[10010][2][110];

    for(int i=0;i<length;i++) {

        for(int j=0;j<2;j++) {

            for(int k=0;k<d;k++) {
                dp[i][j][k] = 0;
            }
        }
    }
    dp[0][0][0] = 1;
    
    for(int i=0;i<length;i++) {

        for(int smaller=0;smaller<2;smaller++) {

            if(smaller==1) {
                lim = 9;
            } else {
                lim = s[i]-'0';
            }

            for(int j=0;j<d;j++) {
                
                for(int k=0;k<lim+1;k++) {
					
                    dp[i+1][smaller || k < lim][(j+k)%d] += dp[i][smaller][j];
                    dp[i+1][smaller || k < lim][(j+k)%d] %= MOD;
                  
                }
            }
        }
    }

    cout << (dp[s.size()][1][0] + dp[s.size()][0][0] - 1 + MOD) % MOD  << endl;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define int  long long
using namespace std;
const int Mod=1e9+7,maxn=2e5+10;
int n,a[maxn],f[maxn],s[maxn],cnt;
signed main()
{
	scanf("%lld",&n);
	for(register int i=1,x;i<=n;i++)
	{ 
		scanf("%lld",&x);
		if(x!=a[cnt])
			a[++cnt]=x;
	}
	f[0]=1;
	for(register int i=1;i<=cnt;i++)
	{
		f[i]=(f[i-1]+s[a[i]])%Mod;
		(s[a[i]]+=f[i-1])%=Mod;
	}
	printf("%lld",f[cnt]);
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

#define arr_print_d0dn(a, n) for(int i=0;i<(n);++i)printf(i==(n)-1?"%d\n":"%d ",(a)[i])

int bubble_sort(int *a, const int N) {
    int flag = 1;
    int head = 0;
    int cnt = 0;
    // flag = 0 -> there is nothing to swap
    while(flag) {
        flag = 0;
        for(int i = N - 1; i > head; --i) {
            if(a[i] < a[i - 1]) {
            // swap
                int tmp = a[i];
                a[i] = a[i - 1];
                a[i - 1] = tmp;
                cnt++;
                flag = 1;
            }
        }
        // A[0 to head]: already sorted
        head++;
    }
    return cnt;
}

int main() {
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; ++i) scanf("%d", a + i);
    int cnt = bubble_sort(a, n);
    arr_print_d0dn(a, n);
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a,b,c;
  cin >> a >> b >>c;
  if(a+b+c>=22) cout<< "bust" <<endl;
  else cout<< "win" <<endl;
}


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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())
#define retunr return
#define No cout<<"No"
#define Yes cout<<"Yes"

//int infiint = std::numeric_limits<int>::max();
//float infiflt = std::numeric_limits<float>::infinity();


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

#ifdef _DEBUG
//  			freopen("input.txt", "r", stdin);
//        freopen("output", "w", stdout);
#endif
    
    string s;
    cin >> s;
    int n=s.size();
    string revv = s;
    reverse(revv.begin(), revv.end());

    if(revv!=s) {
        No;
        return 0;
    }
    string sss;
    revv=s.substr(0,(n-1)/2);
    sss=revv;
    reverse(revv.begin(), revv.end());

    if(sss!=revv)  {
        No;
        return 0;
    }

    revv=s.substr(((n+3)/2)-1, n-((n+3)/2)+1);
    sss=revv;
    reverse(revv.begin(), revv.end());
    if(revv!=sss) {
        No;
        return 0;
    }
    Yes;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
bool comp(lpair l1, lpair l2){
    if(l1.second == l2.second){
        return l1.first < l2.first;
    }
    return l1.second < l2.second;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[200010], B[200010];
    vector<lpair> lp;
    rep(i,0,N){
        cin >> A[i] >> B[i];
        lp.push_back(make_pair(A[i], B[i]));
    }
    sort(lp.begin(), lp.end(), comp);
    bool ok = true;
    ll amari = 0;
    rep(i,0,N){
        if(i == 0){
            amari += lp[i].second;
        }else{
            amari += lp[i].second - lp[i-1].second;
        }
        if(amari >= lp[i].first){
            amari -= lp[i].first;
        }else{
            ok = false;
            break;
        }
    }
    if(ok){
        print("Yes");
    }else{
        print("No");
    }
    
}

Measured memory_bytes: 8816
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}
int digit(int num){
   int cnt=0;
   while(num!=0){
      cnt+=num%10;
      num=num/10;
   }
   return cnt;
}
int main(void){
   int N;
   cin>>N;
   long long x;
   cin>>x;
   vector<long long> a(N);
   vector<long long> result(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end());
   for(int i=0;i<N;i++){
      result[i]=min(x,a[i]);
      x-=result[i];
   }
   result[N-1]+=x;
   int ans=0;
   for(int i=0;i<N;i++){
      if(result[i]==a[i]) ans++;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
import sys
A, B, C = [int(x) for x in input().split()]
ans = 0
if(A==B==C)and(A%2==0)and(B%2==0)and(C%2==0):
  print(-1)
  sys.exit()
while (A%2==0)and(B%2==0)and(C%2==0):
  a = B/2 + C/2
  b = C/2 + A/2
  c = A/2 + B/2
  A, B, C = a, b, c
  ans += 1
print(ans)

Measured memory_bytes: 9172
X ,N = map(int,input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))

    add_minus = -1
    while True:
        add_minus += 1
        if (X - add_minus) not in p:
            print(X - add_minus)
            break
        elif (X + add_minus) not in p:
            print(X+add_minus)
            break
        

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000000000;
ll INF=10000000000000000;


int main(){
    string s;
    cin >> s;
    vector<int> a(s.size(),0);
    int e=0,q=0,w=1,a1,a2;
    rep(i,s.size()){
        if (e==0){
            if (s.at(i)=='L'){
                e=1;
                a1=i-1;
                a2=i;
                continue;
            }
            else q++;
        }
        if (e==1){
            if (s.at(i)=='R'){
                e=0;
                a.at(a1)=q/2+q%2+w/2;
                a.at(a2)=q/2+w/2+w%2;
                q=1;w=1;
            }
            else w++;
        }
    }
    a.at(a1)=q/2+q%2+w/2;
                a.at(a2)=q/2+w/2+w%2;
    rep(i,s.size()-1){
        cout << a.at(i) << " ";
    }
    cout << a.at(s.size()-1) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

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

	ll n = 0;
	cin >> n;
	if(n % 2 == 0)	cout << n;
	else	cout << n * 2 << endl;

	#ifdef LOCAL_DEFINE
		cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>

#include <limits.h>
#include <cmath>

using namespace std;

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

    vector<pair<int, int>> order;
    vector<int> counts;

    int lmin = INT_MAX, rmax = 0;
    for (int i = 0; i < q; i++) {
        int n, m;
        cin >> n;
        cin >> m;
        order.push_back(pair<int, int>(n, m));
        counts.push_back(0);

        lmin = min(lmin, n);
        rmax = max(rmax, m);
    }

    vector<bool> sieve(100001, true);

    sieve[0] = sieve[1] = false;

    for (int i = 2; i < sieve.size(); i++) {
        for (int j = i * 2; j < sieve.size(); j += i)
            sieve[j] = false;
    }

    for (int n = lmin; n <= rmax; n++) {
        if (!(sieve[n] && sieve[(n + 1) / 2]))
            continue;

        for (int i = 0; i < order.size(); i++) {
            if (order[i].first <= n && n <= order[i].second)
                counts[i]++;
        }
    }

    for (auto n: counts)
        cout << n << endl;
}

Measured memory_bytes: 2292
#include<iostream>
#include<vector>
#define MAX 100000
using namespace std;
int main(){
    vector<bool> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=v[1]=false;
    for(int i = 2;i<1000;i++){
      if(v[i]){
        for(int j=i*i;j<MAX;j+=i){
         v[j]=false;
       }
      }
    }
    while(true){
      int a;
      int ans =0;
      cin >> a;
      if(a==0)return 0;
      for(int i = 2;i<=a/2;i++){
        if(v[a-i]&&(v[i]))ans++;
      }
      cout <<ans<<endl;
    }
}



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



int solve(int i, vector<int>& dp, vector<vector<int>>& g)
{
  if (dp[i] != -1)
    return dp[i];
  int res = 0;
  for (auto v : g[i])
    res = max(1 + solve(v, dp, g), res);
  return dp[i] = res;
}


int main()
{
  int n, m, x, y;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> dp(n);
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    x--; y--;
    g[x].push_back(y);
  }

  for (int i = 0; i < n; ++i)
    dp[i] = -1;

  for (int i = 0; i < n; ++i) {
    if (dp[i] == -1)
      solve(i, dp, g);
  }
  int res = 0;

  for (int i = 0; i < n; ++i)
    res = max(res, dp[i]);

  cout << res <<'\n';

  return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
int w, h;
char ma[30][30];
char check[30][30];
int mx[4] = {-1, 0, 1, 0};
int my[4] = {0, -1, 0, 1};
int ans;

void Rec(int x, int y);

int main(void){
	while(1){
		ans = 0;

		cin >> w >> h;
		if(w == 0 && h == 0) break;
		for(int i=0; i<h; i++){
			scanf("%s", ma[i]);
		}

		int sx, sy;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(ma[i][j] == '@'){
					sx = j;
					sy = i;
				}
				check[i][j] = 0;
			}
		}
		
		check[sy][sx] = 1;
		ans++;
		Rec(sx, sy);

		cout << ans << endl;
	}

	return 0;
}

void Rec(int x, int y){
	for(int i=0; i<4; i++){
		int nx = x + mx[i];
		int ny = y + my[i];

		if(nx >= 0 && nx < w && ny >= 0 && ny < h && ma[ny][nx] == '.' && check[ny][nx] == 0){
			check[ny][nx] = 1;
			ans++;
			Rec(nx, ny);
		}
	}
}

Measured memory_bytes: 1196
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	// a<=b

	if a == 0 || b == 0 {
		fmt.Println("Zero")
		return
	}
	if a < 0 && b > 0 {
		fmt.Println("Zero")
		return
	}
	if a > 0 && b > 0 {
		fmt.Println("Positive")
		return
	}

	// a=Nega && b=Nega
	// -3 * -2 * -1
	interval := b - a + 1
	if interval%2 == 0 {
		fmt.Println("Positive")
	} else {
		fmt.Println("Negative")
	}
	return

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

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

  			int a,b,c;
  			cin >> a >> b >>c;
  			cout << c <<" " << a << " "<< b;

  		}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef unsigned long long ull;
int main (void) {
    ull x;
    ull y;
    ull ans = 0;

    cin >> x >> y;

    while (x <= y) {
        x *= 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# 1 - indexed
# 指定したindexに対してaddで数値を足す
# get(L,R)で、L～Rの累積和を求める（両端とも含む）
# 0を指定すると返ってこないので注意
class FenwickTree: # (BinaryIndexedTree)
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i

  def get(self, i, j = None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i - 1)
    
import sys
readline = sys.stdin.readline

N,Q = map(int,readline().split())
A = list(map(int,readline().split()))

FT = FenwickTree(N)

for i in range(len(A)):
  FT.add(i + 1, A[i])
  
for i in range(Q):
  query = list(map(int,readline().split()))
  if query[0] == 0:
    FT.add(query[1] + 1, query[2])
  else:
    print(FT.get(query[1] + 1, query[2]))


Measured memory_bytes: 75424
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

struct Edge {
  int src, dest, weight;
};

int main()
{
  int n;
  cin>>n;
  vector<vector<Edge>> g(n);
  REP(i,n-1) {
    int u,v,w;
    cin>>u>>v>>w;
    --u;--v;
    g[u].push_back((Edge){u, v, w});
    g[v].push_back((Edge){v, u, w});
  }
  vector<bool> clr(n, false);
  vector<bool> vis(n, false);
  queue<int> q;
  q.push(0);
  vis[0] = true;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    for (const Edge& e : g[i]) {
      if (!vis[e.dest]) {
        vis[e.dest] = true;
        clr[e.dest] = e.weight % 2 ? !clr[i] : clr[i];
        q.push(e.dest);
      }
    }
  }
  for (bool c : clr) {
    cout << c << endl;
  }
  return 0;
}


Measured memory_bytes: 6912
a, b, c, x = [int(input()) for i in range(4)]
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1


print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	cin >> s;
	int n = s.size() - 7;
	REP(i, s.size() - n) {
		t = s;
		// p(s.erase(i, n));
		if("keyence" == s.erase(i, n)) {
			ans = 1;
			//p("YES");
		} else {
			//p("NO");
		}
		s = t;
	}
	cout << (ans==1?"YES":"NO") << endl;
}



Measured memory_bytes: 256
#coding:utf-8
import math

N,K = map(int,input().split())

A = [int(y) for y in input().split()]

Ma = max(A)
mi = 1

ans = Ma

def execute(f):
    count = 0
    for i in A:
        count += math.ceil(i / f) - 1
    if count <= K:
        return True
    else:
        return False

while True:
    median = (Ma + mi) // 2
    
    bobo = execute(median)
    
    if bobo:
        ans = min(ans,median)
        Ma = median
    else:
        mi = median + 1
    
    if Ma == mi:
        break

print("{}".format(ans))

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

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

  if (N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  bool result = true;
  for (int i = 0; i < N/2; ++i) {
    if (S.at(i) != S.at(i+N/2)) { result = false; }
  }
  if (result) { cout << "Yes" << endl; }
  else { cout << "No" << endl; }
}

Measured memory_bytes: 256
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N-1): # iは出発駅,0からN-2
    t = 0
    for j in range(i, N-1): # jは今いる駅,iからN-2
        # 待ち時間の加算
        if t < S[j]:
            t += S[j] - t
        else:
            t += (F[j] - (t % F[j])) % F[j]

        # 移動時間の加算
        t += C[j]
    print(t)
print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
           int h,a;
           cin>>h>>a;
           if(h%a==0)cout<<h/a;
           else cout<<h/a +1;
           return 0;

        }


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

int main(){
    int r, g, b;
    int k;
    cin >> r >> g >> b >> k;
    int i= 0;
    bool ans = false;
    while(i < k){
        if( r >= g) g *= 2;
        else if( g >= b) b *= 2;

        if( r < g && g < b) {
            ans = true;
            break;
        }

        i++;
    }

    if(ans) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
int n,a,b;
int dp[1500001];
int main(void){
	while(1){
		scanf("%d %d %d",&n,&a,&b);
		if(n+a+b==0)break;
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		int cnt=-1;
		for(int i=0;i<=n;i++){
			if(dp[i]>0){
				cnt++;
				dp[i+a]=dp[i];
				dp[i+b]=dp[i];
			}
		}
		printf("%d\n",n-cnt);
	}
	return 0;
}

Measured memory_bytes: 6892
N=int(input())
la=list(map(int,input().split()))
lc=[0 for i in range(N+1)]
for a in la:
    lc[a]+=1
#print("lc",lc)
"""
lsum=[0 for i in range(N+1)]
for i in range(N):
    lsum[i+1]=lsum[i]+lc[i+1]*(lc[i+1]-1)//2
"""
sum=0
for i in range(N):
    sum+=lc[i+1]*(lc[i+1]-1)//2
#print("sum",sum)
for i in range(1,N+1):
    #print("kosuu_mae",lc[la[i-1]])
    print(sum-lc[la[i-1]]*(lc[la[i-1]]-1)//2+(lc[la[i-1]]-2)*(lc[la[i-1]]-1)//2)


Measured memory_bytes: 26140
#include<iostream>
using namespace std;
int main()
{
    long long a,b,c,k,num=0;
    cin>>a>>b>>c>>k;
    for(int i=1;i<=k;i++){
        if(i<=a)
            num+=1;
        if(i>a&&i<=b+a)
            num+=0;
        if(i>a+b&&i<=a+b+c)
            num-=1;
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+10;
#define minf -10000000000000000
ll a[N];
ll ans=0;
ll n;
map<pair<ll,ll>,ll>mp,ex;

ll cal(ll taken,ll i)
{
	if(i>n-1)
	{
		if(taken==n/2)
		  return 0;
		else
		  return minf;
	}
	if(taken==n/2)
	  return 0;
	
	if((n-i+1)/2+taken<n/2)
	{
		  return minf;
	}
	
	if(ex[{i,taken}]==1)
	  return mp[{i,taken}]; 
	ll ans;
	ans=max(cal(taken,i+1),a[i]+cal(taken+1,i+2));
	mp[{i,taken}]=ans;
	ex[{i,taken}]=1;
	return ans;		
}


int main()
{

	cin>>n;
	for(int i=0;i<n;i++)
	  cin>>a[i];
	
	  
	  
    cout<<cal(0ll,0ll)<<endl;	
//    for(auto it:mp)
//	{
//	    cout<<"key "<<it.first.first<<" "<<it.first.second<<endl;
//	    cout<<"value ";
//		for(auto it1:it.second)
//		  cout<<it1<<" ";
//		  cout<<endl;	
//	}  
}

Measured memory_bytes: 52028
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
  if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>p[i+1]:
    cnt += 1
    
print(cnt)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

struct nd{
    vector< ll > ady;
}T[200010];

ll n,ans,mod=998244353;
pii r[200010];
stack< ll > s;
vector< ll > roots;

ll fn( ll node ){
    if( T[node].ady.empty() ) return 2;
    ll myAns = 1;
    for(auto sig:T[node].ady){
        myAns = (myAns*fn( sig ))%mod;
    }
    myAns = (myAns+1)%mod;
    return myAns;
}

int main()
{

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

    cin >> n;
    for(int i=0; i<n; i++) cin >> r[i].fi >> r[i].se , r[i].se+=r[i].fi;

    sort( r , r+n );

    for(ll i=0; i<n; i++){
        while( !s.empty() && r[ s.top() ].se <= r[ i ].fi ) s.pop();
        if( s.empty() ){
            roots.pb( i );
            s.push( i );
        }else{
            T[ s.top() ].ady.pb( i );
            s.push( i );
        }
    }

    ans = fn( roots[ 0 ] );
    for(ll i=1; i<roots.size(); i++) ans = (ans*fn( roots[i] ))%mod;

    cout << ans;

    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

double A;
double B;

int main()
{
    cin >> A >> B;
    double result = (A + B) / 2.0 + 0.5;

    cout << static_cast<int>(result) << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=0
b=0
c=0
for i in range(1,int(n**(1/2))+1):
	if i**2<=n:
		a=i
for i in range(a,0,-1):
	if n%i==0:
		b=i
		c=n//i
		break
print(b+c-2)

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
A, B, H, M = list(map(int, input().split()))

# 求解処理
PI = math.pi
angle_A = PI * H / 6 + PI * M / 360
angle_B = PI * M / 30
angle = max(angle_A, angle_B) - min(angle_A, angle_B)
result = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))

# 結果出力
print(result)


Measured memory_bytes: 9504
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[555555];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	int n=s.length()+1;
	memset(a,-1,sizeof(a));
	vi zeroes;
	for(int i=0;i+1<s.length();i++)
	{
		if(s[i]=='>'&&s[i+1]=='<')
		{
			a[i+1]=0; zeroes.pb(i+1);
		}
	}
	if(s[0]=='<') 
	{
		a[0]=0; zeroes.pb(0);
	}
	if(s[int(s.length())-1]=='>') 
	{
		a[n-1]=0;
		zeroes.pb(n-1);
	}
	for(int z:zeroes)
	{
		//right
		int oriz=z;
		while(z+1<n)
		{
			if(s[z]=='<')
			{
				a[z+1]=max(a[z+1],a[z]+1);
				z++;
			}
			else break;
		}
		z=oriz;
		//left
		while(z>0)
		{
			if(s[z-1]=='>')
			{
				a[z-1]=max(a[z-1],a[z]+1);
				z--;
			}
			else break;
		}
	}
	/*
	for(int i=0;i<n;i++)
	{
		cerr<<a[i]<<' ';
	}
	cerr<<'\n';
	*/
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<'\n';
}	


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

int main() {
  string s; cin >> s;
  sort(s.begin(), s.end());
  cout << (s.at(0)=='a' && s.at(1)=='b' && s.at(2)=='c' ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Computation of Salary
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0286

"""
import sys


def solve(N, M, log):
    prices = [int(p) for p in input().split()]
    res = [dict() for _ in range(N+1)]
    for s, t, e in log:
        res[s][t] = res[s].get(t, 0) + e
    return [sum([prices[k - 1] * v for k, v in r.items()]) for r in res[1:]]


def main(args):
    N, M = map(int, input().split())
    log = []
    while True:
        s, t, e = map(int, input().split())
        if s == 0 and t == 0 and e == 0:
            break
        log.append((s, t, e))
    L = int(input())
    for _ in range(L):
        ans = solve(N, M, log)
        print(*ans, sep=' ')


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 17748
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=300005;
/*int f[N],use[N],a[N],n,mn=1e9,mx=0;
inline void check()
{
	register int i,j,mx1=0,mx2=0;
	for(i=1;i<=n;i++)
	{
		f[i]=1;
		for(j=1;j<i;j++)
			if(a[j]<a[i])	f[i]=max(f[i],f[j]+1);
		mx1=max(mx1,f[i]);
	}
	for(i=1;i<=n;i++)
	{
		f[i]=1;
		for(j=1;j<i;j++)
			if(a[j]>a[i])	f[i]=max(f[i],f[j]+1);
		mx2=max(mx2,f[i]);
	}
	if(mx1+mx2<n/2+2||mx1+mx2>n+1)
	{
//		for(i=1;i<=n;i++)	printf("%d ",a[i]);
//		printf("mx1=%d mx2=%d sum=%d\n",mx1,mx2,mx1+mx2);
	}
	mn=min(mn,mx1+mx2);
	mx=max(mx,mx1+mx2);
}
void dfs(int x)
{
	if(x==n+1)	check();
	else
	{
		for(int i=1;i<=n;i++)	if(!use[i])
		{
			use[i]=1;a[x]=i;
			dfs(x+1);
			use[i]=0;
		}
	}
}*/
vector<int> v[N];
inline void gg()
{
	puts("-1");
	exit(0);
}
int main()
{
/*	n=ri();
	dfs(1);
	printf("mn=%d mx=%d\n",mn,mx);*/
	int n=ri(),a=ri(),b=ri(),j,i,d=n/a,now=n-a+1,tot=d;
	for(i=1;i<=d;i++,now-=a)
		for(j=1;j<=a;j++)
			v[i].push_back(now+j-1);
	if(n%a)
	{
		tot++;
		for(j=1;j<=n%a;j++)
			v[tot].push_back(j);
//		reverse(v[tot].begin(),v[tot].end());
	}
	if(1ll*a*b<n||a+b>n+1)	gg();b-=tot;
/*	for(i=1;i<=tot;i++)
		for(j=0;j<v[i].size();j++)
			printf("i=%d %d\n",i,v[i][j]);*/
	for(i=tot;i>1;b-=v[i].size()-1,i--)
	{
		if(b<v[i].size()-1)	break;
		reverse(v[i].begin(),v[i].end());
	}
	if(b)
	{
		reverse(v[i].begin(),v[i].begin()+b+1);
	}
	for(i=1;i<=tot;i++)
		for(j=0;j<v[i].size();j++)
			printf("%d ",v[i][j]);
	puts("");
	return 0;
}


Measured memory_bytes: 11008
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ac = 0;
    int tle = 0;
    int re = 0;
    int wa = 0;

    string p;
    while(n--)
    {
        cin>>p;
        if(p == "AC")
        {
            ac++;
        }
        else if(p == "TLE")
        {
            tle++;
        }
        else if(p == "WA")
        {
            wa++;
        }
        else
        {

            re++;
        }
    }
    
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";

}


Measured memory_bytes: 3596
object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
        for (Array(d, e) <- in if d != 0 || e != 0) {
            println((0 to d / 2).map(n => math.abs(math.sqrt((d - n) * (d - n) + n * n) - e)).min)
        }
    }
}

Measured memory_bytes: 44724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
ll yu(ll a, ll b){
    if(a < b) swap(a,b);
    ll y = b;
    while(y!=0){
        y = a % b;
        a = b;
        b = y;
    }
    return a;
}


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

    
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    int f = a[0];
    for(int i = 1; i < n;i++){
        f = yu(f,a[i]);
    }

    cout << f << endl;

    return 0;
}

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

public class Main{
    
    public static void main(String[] args) throws IOException {
        Reader.init();
        int N=Reader.nextInt();
      	int V[]=new int[N];
      	read(V, N);
      	PriorityQueue<Double> PQ=new PriorityQueue();
      	for(int i:V){
        	PQ.add((double)i);
        }
      	while(PQ.size()>1){
        	double a=PQ.poll();
          	double b=PQ.poll();
          	PQ.add((a+b)/2);
        }
      	print(PQ.poll());
      
    }

    static int mod=1000000007;
    
    public static void read(int arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextInt(); } }
    public static void read(String arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.next(); } }
    
    public static void print(Object O){ System.out.println(O); }
    
    public static void display(int arr[]){ System.out.println(Arrays.toString(arr)); }
    public static void display(int arr[][], int N){ for(int i=0;i<N;i++){ System.out.println(Arrays.toString(arr[i])); } }
  
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init() {
        reader=new BufferedReader(new InputStreamReader(System.in));
        tokenizer=new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) {
            tokenizer=new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException { return Integer.parseInt(next()); }
    static double nextDouble() throws IOException { return Double.parseDouble(next()); }
    static long nextLong() throws IOException { return Long.parseLong(next()); }
    static String nextLine() throws IOException { return reader.readLine(); }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define oset tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k.
//find_by_order(k) : K-th element in a set (counting from zero).

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    vector<ll> dp(n);
    dp[0]=0; dp[1]=abs(a[0]-a[1]);
    for(ll i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1];


    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 4812
#include <stdio.h>


int main(void){
	long long int L[87];
	
	int i, N;

	scanf("%ld", &N);
	L[0]=2;L[1]=1;
	for (i = 2; i <= N; i++){
		L[i]=L[i-2]+L[i-1];
	}
	printf("%lld\n", L[N]);
	return 0;
}

Measured memory_bytes: 128
n,d=map(int,input().split())
i=0
s=[]
s2=[]
while i!=n:
    s2=list(map(int,input().split()))
    i+=1
    s.append(s2)

ans=0
sans=[]
i=0
j=0
k=0
sum=0
while i!=n:
    while j!=n:
        if i!=j:
            while k!=d:
                sum+=(s[i][k]-s[j][k])**2
                k+=1
            sans.append(sum**(1/2))
        sum=0
        k=0
        j+=1
    i+=1
    j=0
i=0
#print(sans)
while True:
    try:
        if sans[i]%1==0.0:
            ans+=1
        i+=1
    except:
        break
print(int(ans/2))

Measured memory_bytes: 3064
a,b,k = map(int,input().split())

abmin = min(a,b)
nums = []
for i in range(abmin):
    if a % (i + 1) == 0 and b % (i+1) == 0:
        nums.append(i+1)

list.sort(nums,reverse=True)
print(nums[k-1])



Measured memory_bytes: 2940
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll x;
int main(){ //srand((unsigned)time(NULL));
  cin >> x;
  cout << x*x*x << endl;
}



Measured memory_bytes: 3108
n, m = gets.chomp.split.map(&:to_i)
ab = (0...n).map{gets.chomp.split.map(&:to_i)}
cd = (0...m).map{gets.chomp.split.map(&:to_i)}

puts ab.inject([]){|arr, (a, b)|
    l = 10**9
    checkpoint = 1
    
    cd.each_with_index.map{|(c, d), i| 
        if (a-c).abs + (b-d).abs < l then
            l = (a-c).abs + (b-d).abs
            checkpoint = i + 1
        end
    }
    
    arr << checkpoint
}

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

#define MAX_N 200000
#define MAX_M 200000
#define MOD 1000000007

#define INF 1 << 29

int N, M;
string S;

long long dp[MAX_N + 2], rdp[MAX_N + 2];

int all_color_is_same()
{
    long long rr = 1, bb = 1, rb = 0, br = 0;

    for ( int i = 1; i < N; i++ )
    {
        long long nrr = ( rr + rb ) % MOD;
        long long nbb = br;
        long long nrb = rr;
        long long nbr = ( bb + br ) % MOD;

        rr = nrr;
        bb = nbb;
        rb = nrb;
        br = nbr;
    }

    return ( rr + rb + br ) % MOD;
}

/* S
の先頭の文字の最小連続回数を求める。ただし連続回数が偶数のものは無視する。
*/
int min_freq()
{
    int l = 0;
    while ( l < M && S[0] == S[l] ) l++;

    int ans = ( l & 1 ) ? l : l + 1;

    l = 0;
    for ( int i = 0; i < M; i++ )
    {
        if ( S[0] == S[i] )
            l++;
        else
        {
            if ( l & 1 ) ans = min( ans, l );
            l = 0;
        }
    }
    return ans;
}

int solve()
{
    // 一色
    if ( S.find( "R" ) == string::npos || S.find( "B" ) == string::npos )
        return all_color_is_same();

    // N が奇数
    if ( N & 1 ) return 0;

    int L = min_freq();

    L = ( L + 1 ) >> 1;
    N >>= 1;

    dp[0] = rdp[0] = 1;
    for ( int i = 1; i <= N + 1; i++ )
    {
        dp[i] = rdp[i - 1];
        if ( i - L - 1 >= 0 ) dp[i] = ( dp[i] - rdp[i - L - 1] ) % MOD;
        if ( dp[i] < 0 ) dp[i] += MOD;
        rdp[i] = ( rdp[i - 1] + dp[i] ) % MOD;
    }

    long long res = 0;
    for ( int i = 1; i <= L; i++ )
        if ( N >= i ) res = ( res + dp[N - i] * 2 * i ) % MOD;

    return res % MOD;
}

int main( int argc, char **argv )
{
    cin >> N >> M;
    cin >> S;

    int ans = solve();

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2180
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;

int main(void){
 double N,K,ans;
 vector<int> A; 
 
 A.push_back(1);
 for(int i=1;i<=100000;){
  i*=2;
  A.push_back(i);
 }

 cin>>N>>K;
 ans=0.0;
 for(int i=1; i<=N; i++){
  for(int j=0;j<A.size();j++){
    if(i*A[j]>=K){
     ans+=(1.0/N/A[j]);
     break;
    }
  }
 }
 cout<<fixed;
 cout<<setprecision(15)<<ans<<endl;
 return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll n, m, R;
    cin >> n >> m >> R;
    
    vector<ll> r(R);
    REP(i, R){
        cin >> r[i];
        r[i]--;
    }
    
    vector<vector<ll>> w(n, vector<ll>(n, INF));
    REP(i, n){
        w[i][i] = 0;
    }
    REP(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        
        w[a][b] = c;
        w[b][a] = c;
    }
    
    REP(k, n){
        REP(i, n){
            REP(j, n){
                w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
            }
        }
    }
    
    sort(r.begin(), r.end());
    
    ll ans = INF;
    do{
        ll sum = 0;
        for(ll i = 1; i < R; i++){
            sum += w[r[i - 1]][r[i]];
        }
        ans = min(ans, sum);
    }while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}

Measured memory_bytes: 512