akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            var X = Calc(B);
            var A_ = Calc(A - 1);
            WriteLine(X ^ A_);
        }
        static long Calc(long N)
        {
            if (N < 0) return 0;
            var m = N % 4;
            if (m == 0) return N;
            if (m == 1) return 1;
            if (m == 2) return 1 ^ N;
            return 0;
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27548
# 2020/01/30
# AtCoder Beginner Contest 064 - C

# Input
n = int(input())
a = list(map(int, input().split()))

# Count
ans = 0

a.sort()
wk_r = -1
a_max = 0
cnt = 0
for i in range(n):
    if a[i] >= 3200:
        a_max = cnt + (n - i)
        break
    
    rank = a[i] // 400
    if wk_r != rank:
        cnt = cnt + 1
        wk_r = rank

a_min = max(1, cnt)
if a[n-1] < 3200:
    a_max = cnt

# Output
print(a_min, a_max)

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

int main(){
  int n,m;
  std::cin >> n>>m;
  std::vector<P> s;
  std::vector<P> c;
  rep(i,n){
    int t1,t2;
    std::cin >> t1>>t2;
    s.push_back(P(t1,t2));
  }
  rep(i,m){
    int t1,t2;
    std::cin >> t1>>t2;
    c.push_back(P(t1,t2));
  }


  rep(i,n){
    ll cost=100100100100100;
    int p=0;
    ll nx=s[i].first;
    ll ny=s[i].second;
    rep(j,m){
      ll now=abs(nx-c[j].first)+abs(ny-c[j].second);
      if(cost>now){
        cost=now;
        p=j+1;
      }
    }
    std::cout << p<< '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,x=0;
    cin>>n;
    int a[n+1];
    string s;
    cin>>s;
    a[0]=0;
    for(int i=0;i<n;i++){
        if(s[i]=='I')
           x++;
        else if(s[i]=='D')
            x--;
        a[i+1]=x;
    }
    cout<<*max_element(a,a+n+1);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
int a[100000];
int main(void)
{
	int n,i,k=0;
	ll sum=0;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",a+i);
	qsort(a,n,sizeof(int),comp);
	FOR(i,0,n){
		if(sum*2<a[i]) k=i;
		sum+=a[i];
	}
	printf("%d\n",n-k);
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cout << " >> " << #x << " "<<x<<endl;
int N;
void Solve_Case()
{
   cin >> N;
   vector<int> v(N);
   for(auto &i : v) cin >> i;
   priority_queue<double> Q;
   for(auto i  : v)
   {
       Q.push(-i);
   }
   while(Q.size() != 1)
   {
       double Top1 = -Q.top();
       Q.pop();
    double Top2 = -Q.top();
       Q.pop();
       Q.push(-( Top1 + Top2) / 2.0);
    }
    cout <<  -Q.top() ;
}
signed main()
{
    int TestCases = 1;

    while(TestCases--)
    {
        Solve_Case();
    }
	return 0;
}


Measured memory_bytes: 256
import random
def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in xrange(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n=input()
ans=0
for i in range(n):
    p=input()
    if is_prime(p):
        ans+=1
print ans

Measured memory_bytes: 5704
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: u64,
        s: [String; n],
    }

    let mut hs = HashSet::new();
    for i in s {
        hs.insert(i);
    }
    println!("{}", hs.len());
}


Measured memory_bytes: 24808
#include<bits/stdc++.h>
#include<vector>
#define inf 10000000000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;
// lower_bound 
 // it returns pos of the elmnt which is not less then the query elmnt
int main(){
    int n, flag = 0; cin >> n;
    string str; cin >> str;
    unordered_map<char, int>mp;
    for(auto i : str)
        mp[i]++;

    int freq = mp[str[0]];

    for(auto i  : mp){
        if(i.second % 2 != 0){
            flag=1;break;
        }
    }

    if(flag == 1 || str.size() == 1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

}




Measured memory_bytes: 3580
x , n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = set(map(int,input().split()))
i = 0
while True:
    e = x-i
    if not e in p:
        print(x-i)
        exit()
    d = x+i
    if not d in p:
        print(x+i)
        exit()

    i += 1

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
  ll a , b;
}a0[ 201000 ];
ll a1[ 201000 ] , n , t ;
ll dp[ 201000 ] , cnt1 , cnt2 , ans;  

bool mycmp( node x , node y ){
	return y.a* x.b < x.a * y.b ;  
}
int main( ){
   dp[ 0 ] = 0;
  scanf("%lld%lld" , &n , &t );
   for( int i = 1 ; i <= 31 ; i ++ ) dp[ i ] = t + 1;
  for( int i = 1 ; i <= n ; i ++ ){
   ll a , b;
   scanf("%lld%lld" , &a , &b );
   b ++ ; b += a;
   if( a == 0 ) a1[ ++cnt1 ] = b;else 
   a0[ ++cnt2 ] = { a , b };    
  }
  sort( a0 + 1 , a0 + cnt2 + 1 , mycmp );
	sort( a1 + 1 , a1 + cnt1 + 1 );
	for( int i = 1 ; i <= cnt2 ; i ++ ){
	for( int j = 30 ; j >= 0 ; j -- ){
			if( dp[ j ] <= t ) 
			 dp[ j + 1 ] = min( dp[ j + 1 ] , dp[ j ] + a0[ i ].a * dp[ j ] + a0[ i ].b );
	}
	}
	for( int i = 0 ; i <= 30 ; i ++ ){
		if( dp[ i ] <= t ){
         ll lef = t - dp[ i ] , num = i ;
			for( int j = 1 ; j <= cnt1 ; j ++ ){
			 if( lef < a1[ j ] ) break;
			 lef -= a1[ j ];
			 num ++;
		   }
		   ans = max( ans , num );
	   }
    }
	 
	printf("%lld" , ans );
}

Measured memory_bytes: 6864
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ldb;//can store 2^80;
ll i,j,k,t,n,a,b,c,sum1,sum2,m,p;
string s1,s2;
//1e-9 == 10^-9 && 1e9==10^9;
#define rep(i,a,n) for(i=a;i<n;++i)
#define fst first
#define snd second
#define sq(a) (a)*(a)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
typedef vector<ll> vl;
typedef pair<ll,ll> pl;
typedef map<ll,ll> mp;
int main(){
	char ch;
	cin>>a>>ch>>b;
	if(ch=='+')cout<<a+b;
	else cout<<a-b;
}

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
A.sort()
bl = [True] * (A[-1]+1)
answer = 0
for i, a in enumerate(A):
    if i < N-1 and A[i+1] == a:
        pass
    elif bl[a]:
        answer += 1
    if bl[a]:
        bl[a] = False
        next = a + a
        while next <= A[-1]:
            bl[next] = False
            next += a

print(answer)


Measured memory_bytes: 106452
#include <bits/stdc++.h>
using namespace std;
#define MAX 100010

int main(){
  queue<pair<string,int>>A;
  int n,q;
  scanf("%d %d",&n,&q);
  for(int i=0;i<n;i++){
    string p;int a;
    cin>>p>>a;
    A.push(make_pair(p,a));
  }
  int c,elapse=0;
  pair<string,int>u;
  while(A.size()>0){
    u=A.front();A.pop();
    c=min(q,u.second);
    elapse+=c;
    u.second-=c;
    if(u.second>0){
      A.push(u);
    }
    else{
      cout << u.first << " " <<elapse<<endl;
    }
  }
}


Measured memory_bytes: 6292
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		int[] left = new int[n];
		left[0] = arr[0];
		for (int i = 1; i < n; i++) {
			left[i] = gcd(left[i - 1], arr[i]);
		}
		int[] right = new int[n];
		right[n - 1] = arr[n - 1];
		for(int i = n - 2; i >= 0; i--) {
			right[i] = gcd(right[i + 1], arr[i]);
		}
		int max = 0;
		for (int i = 1; i < n - 1; i++) {
			int g = gcd(left[i - 1], right[i + 1]);
			max = Math.max(max, g);
		}
		max = Math.max(max, right[1]);
		max = Math.max(max, left[n - 2]);
		System.out.println(max);
	}
	
	static int gcd(int a, int b){
		if (a % b == 0) {
			return b;
		}
		return gcd(b, a % b);
	}
}


Measured memory_bytes: 50080
#include <iostream>
#include <omp.h>
#include <cmath>
#include <algorithm>
using namespace std;

int gcd(int hi,int hj, int hk){
    int i=hi,j=hj,k=hk;
    while(i!=j || i!=k){
        if(i>k){
            if(i>j)
            i-=min(j,k);
            else if(j>i)
            j-=k;
            else{
                i-=k;j-=k;
            }
        }else if(k>i){
            if(k>j)
            k-=min(i,k);
            else if(j>k)
            j-=i;
            else{
                k-=i;j-=i;
            }
        }else{
            if(k>j){
                k-=j;
                i-=j;
            }else if(j>k)
            j-=i;
        }
    }
    return i;
}

int main() {
    int n,res=0;
    cin>>n;
    #pragma omp parallel for
    for(int i=1;i<=n;++i){
        #pragma omp parallel for
        for(int j=1;j<=n;++j){
            #pragma omp parallel for reduction(+,res)
            for(int k=1;k<=n;++k){
                res+=gcd(i,j,k);
            }
        }
    }
    cout<<res;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  REP(t,k) {
    vector<int> sim(n+1);
    REP(i,n) {
      int l = max(0,i-a[i]);
      int r = min(n,i+a[i]+1);
      ++sim[l];
      --sim[r];
    }
    REP(i,n) sim[i+1]+=sim[i];
    REP(i,n) a[i] = sim[i];
    bool flag=true;
    REP(i,n) if(a[i]!=n) flag=false;
    if(flag) break;
  }
  REP(i,n) {
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4844
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    s=input()
    q=int(input())
    s=deque(s)
    inv=False
    for i in range(q):
        que=input()
        if que[0]=='1':
            inv=not(inv)
        else:
            f=que[2]
            if (f=='1' and not(inv)) or (f=='2' and inv):
                s.appendleft(que[4])
            else:
                s.append(que[4])
    if inv:s.reverse()
    print(*s,sep='')

if __name__=='__main__':
    main()

Measured memory_bytes: 12272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int day[]={20,19,20,19,20,19,20,19,20,19,20,19,20,19};
    int day3[]={20,20,20,20,20,20,20,20,20,20,20,20,20,20};
    int n;
    cin>>n;
    rep(p,0,n){
        int y,m,d;
        int ans=0;
        cin>>y>>m>>d;
        y--; m--; d--;
        while(1){
            rep(i,y,1001){
                if(i==1000){
                    cout<<ans-195<<endl;
                    goto A;
                }
                rep(j,m,10){
                    if((i+1)%3==0){
                        rep(k,d,day3[j])ans++;
                    }else {
                        rep(k,d,day[j])ans++;
                    }
                    d=0;
                }
                m=0;
            }
        }
        A:;
    }
    
    return 0;
}



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

int main() {
   string n;
  cin>>n;
  
   if(n[0]==n[1] && n[1]==n[2] ) cout<<"Yes"<<endl;
  
   else if(n[1]==n[2] && n[2]==n[3] ) cout<<"Yes"<<endl;
  
   else cout<<"No"<<endl;
}

Measured memory_bytes: 384
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N,T,A;
	cin >> N>>T>>A;
	ll H[N];
	for (ll i = 0; i < N; ++i) cin >> H[i];
 
	// 解法
	
	ll ans = -1;
	float min_t = 1e18;
	REP(i, N){
		// float t = float(T) + float(H[i])*0.006;
		float t = T - H[i]*0.006;
		// cout << t << endl;
		float t_abs;
		if (A>t) t_abs = A-t;
		else t_abs = t-A;
		// cout << t_abs << endl;
		if (t_abs<min_t){
			ans = i+1;
			min_t = t_abs;
		}
	}
	
	//出力
	cout << ans << endl;
}


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

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll n,y;
    cin>>n>>y;
    rep(i,0,n+1){
        rep(j,0,n+1) {
            ll k = n-i-j;
            if (k<0)
                continue;
            if (10000*i + 5000*j + 1000*k == y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_h
//shauryakr 
#include<bits/stdc++.h>
using namespace std;
char mat[1005][1005];
long long int mod= 1e9+7;
int n, m;
long long int dp[1005][1005];
long long int dfs(int i, int j)
{
    if(i==n-1 && j==m-1)
    {
        return 1;
    }
    if(dp[i][j] != -1)
        return dp[i][j];
    long long int ans = 0;
    if(i+1 < n && mat[i+1][j] != '#')
    {
        ans = dfs(i+1, j);
    }
    if(j+1 < m && mat[i][j+1] != '#')
    {
        ans = (ans + dfs(i, j+1))%mod;
    }
    dp[i][j] = ans;
    return ans;
}

int main()
{
    cin >> n >> m;
    for(int i=0; i<n; i++)
    {
        cin >> mat[i];
    }
    memset(dp, -1, sizeof dp);
    cout << dfs(0, 0) << endl;
    return 0;
}

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

int main() {
    for(int N; cin >> N, N; ) {
        string S; cin >> S;
        vector<int> cnt(N, 0);
        int field = 0;
        for(int i = 0; i < (int)S.length(); i++) {
            char c = S[i];
            if(c == 'M') {
                cnt[i%N]++;
            }
            else if(c == 'S') {
                field += 1 + cnt[i%N];
                cnt[i%N] = 0;
            }
            else {
                cnt[i%N] += 1 + field;
                field = 0;
            }
        }
        sort(cnt.begin(), cnt.end());
        for(int i = 0; i < N; i++) {
            cout << cnt[i] << ' ';
        }
        cout << field << endl;
    }
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}


const ll MAXN = 13;
const ll MAXM = 1010;
ll dp[MAXM][1ll<<MAXN];
ll N, M;
ll A[MAXM];
ll B[MAXM];
ll C[MAXM]{};

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	REP(m, M)
	{
		cin >> A[m] >> B[m];
		REP(i, B[m])
		{
			ll t;
			cin >> t;
			--t;
			C[m] |= (1ll<<t);
		}
	}

	ll BMAX = 1ll<<N;
	REP(b, BMAX)REP(m, MAXM) dp[m][b] = INF;
	**dp = 0;
	
	REP(i, M)
	{
		REP(bits, BMAX)
		{
			chmin(dp[i+1][bits], dp[i][bits]);
			ll boxs = bits | C[i];
			chmin(dp[i+1][boxs], dp[i][bits]+A[i]);
		}
	}

	ll res = dp[M][BMAX-1];
	std::cout << (res == INF ? -1 : res) << std::endl;
}


Measured memory_bytes: 63488
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
typedef long long ll;
typedef long double ld;
const int MAXI=INT_MAX;
const ll MAXL=LLONG_MAX;
const ll Max=1e18;
ll n,a[maxn];
int main(){
    /*freopen("TASK.inp","r",stdin);
      freopen("TASK.out","w",stdout);*/
    ios_base::sync_with_stdio(0);
    bool ck = true;
    ll ans = 1;
    ll dem = 0;
    cin>>n;
    for (int i = 1; i<=n; i++){
        cin>>a[i];
        if (a[i] == 0) dem++;
    }
    if (dem != 0) cout << 0 << endl;
    else{
        for (int i = 1; i <= n; i++){
            ld l = Max/a[i];
            if (l >= ans){
                ans *= a[i];
            }
            else{
                ck = false;
                break;
            }
        }
        if (ck)  cout << ans << endl;
        else cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 4432
n = int(input())
s = list(input())

p = 0
res = 0

for e in s:
    if e == 'A':
        p = 1
    elif p == 1 and e == 'B':
        p += 1
    elif p == 2 and e == 'C':
        p = 0
        res += 1
    else:
        p = 0
print(res)

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

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<vector<int>> next(60, vector<int>(N));
  for (int v = 0; v < N; ++v) cin >> next[0][v], --next[0][v];
  for (int d = 0; d + 1 < 60; ++d) {
    for (int v = 0; v < N; ++v) {
      next[d + 1][v] = next[d][next[d][v]];
    }
  }
  int v = 0;
  for (int d = 0; d < 60; ++d) {
    if (K & (1LL << d)) v = next[d][v];
  }
  cout << v + 1 << endl;
}


Measured memory_bytes: 51000
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
/*#if !defined(YCM) && 0
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")
#include <stdio.h>
#endif*/
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
    freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
    //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
    //freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        //cerr << testNum << endl;
        solve(true);
        //cerr << testNum - 1 << endl;
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
    sort(all(a));
    a.erase(unique(all(a)), a.end());
}

template<typename T>
void relax_min(T& cur, T val) {
    cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
    cur = max(cur, val);
}

void precalc() {}

//#define int li
//const int mod = 1000000007;

void solve(bool read) {
    string s;
    cin >> s;
    vector<int> num(3);
    for (char c : s) {
        ++num[c - 'a'];
    }
    sort(all(num));
    if (num.back() - num[0] <= 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

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

int main(){
    int N;
    int K;
    
    cin >> N >> K;
    vector<int> h(N);

    for(int i = 0;i < N;i++){
      cin >> h.at(i);
    }
    int ans = 0;
    for(int i = 0;i < N;i++){
      if(h.at(i) >= K){
      ans++;
      }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

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

const long long maxn = 2e5 + 5;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

ll n, low, high, mid;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n;
	low = 1, high = 145;
	for(int i = 145; i >= 1; i--){
		ll x = i;
		ll t = (x + 8) / 9;
		ll n1 = x % 9;
		ll s = 0;
		if(i == 1)
			return cout << 1 << endl, 0;
		if(n1 == 0){
			for(int j = 0; j < t; j++)
				s = s * 10 + 9;
			if(s <= n)
				return cout << i << endl, 0;
			continue;
		}
		s = n1;
		for(int j = 0; j < t - 1; j++)
			s = s * 10 + 9;
		if(s <= n)
			return cout << i << endl, 0;		
	}
	cout << low << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    A = []
    max1_num, max2_num = 0, 0
    for i in range(N):
        a = int(input())
        A.append(a)

        if a >= max1_num:
            max1_num, max2_num = a, max1_num
        elif a > max2_num:
            max2_num = a

    """方針
    最大値と、2番めに大きい値を覚えておく。
    除く値が最大値のとき、答えは2番めに大きい値。それ以外は最大値が答え。
    """

    for a in A:
        if a == max1_num:
            print(max2_num)
        else:
            print(max1_num)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 12532
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 

 
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m,i,j,x,t;
   cin>>n>>m;

   vi v(n+1);
   fo(i,0,m){
   	cin>>x;
   	fo(j,0,x){
   		cin>>t;
   		v[t]++;
   	}
   }
   int cnt=0;
   fo(i,1,n+1){
   	if(v[i]==0)cnt++;
   }
   cout<<cnt;

   
   
   
    return 0;
}

Measured memory_bytes: 3652
s = input()
s1 = int(s[0:2])
s2 = int(s[2:])

if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s1 <= 12:
    print("MMYY")
elif 1 <= s2 <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
  
int main() {
  int x, y, cnt = 0;
  cin >> x >> y;
  while (!(x == 0 && y == 0)) {
    for (int i = 1; i <= (x-2) ; i++){
      for (int j = i+1; j <= (x-1) ; j++){
        for (int k = j+1; k <= x ; k++){
          if (i+j+k == y) {cnt++;}
        }
      }
    }
    cout << cnt << endl;
    cnt = 0;
    cin >> x >> y;
  }
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

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

  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  rep(i, N) {
    cin >> C[i];
    rep(j, M) {
      cin >> A[i][j];
    }
  }

  int ans = INF;
  rep(b, bit(N)) {
    int cost = 0;
    vector<int> x(M);
    rep(i, N) {
      if ((b >> i) & 1) {
        cost += C[i];
        rep(j, M) {
          x[j] += A[i][j];
        }
      }
    }
    bool ok = true;
    rep(j, M) {
      if (x[j] < X)
        ok = false;
    }

    if (ok)
      chmin(ans, cost);
  }

  if (ans == INF)
    ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 3660
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = new long[](N);
	foreach (i; 0..N)
	{
		A[i] = RD;
	}

	long ans;
	foreach (i; 0..N)
	{
		if (i != 0)
		{
			if (A[i-1] != 0 && A[i] != 0)
			{
				++ans;
				--A[i-1];
				--A[i];
			}
		}
		auto x = A[i] / 2;
		ans   += x;
		A[i]  -= x * 2;
		debug writeln(ans);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 4092
import numpy as np

X = int(input())

dp = np.zeros(X + 1)

if X >= 105:
    dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = dp[105] = 1
elif X >= 104:
    dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = 1
elif X >= 103:
    dp[100] = dp[101] = dp[102] = dp[103] = 1
elif X >= 102:
    dp[100] = dp[101] = dp[102] = 1
elif X >= 101:
    dp[100] = dp[101] = 1
elif X >= 100:
    dp[100] = 1


for i in range(106, X+1):
    if dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]:
        dp[i] = 1

print(int(dp[X]))


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

using namespace std;

class Dice {
    public:
        int value[6];
        Dice(int* num);
        void rotate(char direction);
};

//constructor
Dice::Dice(int *num) {
    for (int i = 0; i < 6; i++)
    {
        Dice::value[i] = num[i];
    }
};

void Dice::rotate(char direction) {
    int tmp;
    switch(direction) {
        case 'N':
            tmp = Dice::value[0];
            Dice::value[0] = Dice::value[1];
            Dice::value[1] = Dice::value[5];
            Dice::value[5] = Dice::value[4];
            Dice::value[4] = tmp;
            break;

        case 'S':
            tmp = Dice::value[0];
            Dice::value[0] = Dice::value[4];
            Dice::value[4] = Dice::value[5];
            Dice::value[5] = Dice::value[1];
            Dice::value[1] = tmp;
            break;

        case 'W':
            tmp = Dice::value[0];
            Dice::value[0] = Dice::value[2];
            Dice::value[2] = Dice::value[5];
            Dice::value[5] = Dice::value[3];
            Dice::value[3] = tmp;
            break;

        case 'E':
            tmp = Dice::value[0];
            Dice::value[0] = Dice::value[3];
            Dice::value[3] = Dice::value[5];
            Dice::value[5] = Dice::value[2];
            Dice::value[2] = tmp;
            break;

        default:
        ;
    }
}

int main() {
    int num[6] = {};
    string s;
    for(int i = 0; i < 6; i++) {
        cin >> num[i];
    }
    Dice dice1 = Dice(num);
    cin >> s;
    for(int i = 0; i < s.length(); i++) {
        dice1.rotate(s[i]);
    }
    cout << dice1.value[0] << endl;
    return 0;
}


Measured memory_bytes: 3184
import itertools

takoyaki_num = int(input())
takoyaki_hp = input().split()

takoyaki_combi = itertools.combinations(takoyaki_hp , 2)
heal_hp = 0
for takoyakis in list(takoyaki_combi):
    heal_hp_of = 1
    for takoyaki in takoyakis:
        heal_hp_of *= int(takoyaki)
    heal_hp += heal_hp_of
print(heal_hp)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int sengetsu[101000][2];
int c;
string s;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(7);

    while (getline(cin, s))
    {
        if (s == "")
        {
            c++;
            if (c == 2)
                break;
            continue;
        }

        string T[2];
        T[0] = "";
        T[1] = "";
        int ok = 0;
        for (int i = 0; i < (int)s.size(); ++i)
        {
            if (s[i] == ',')
            {
                ok++;
            }
            else
            {
                T[ok] += s[i];
            }
        }
        int v;
        std::istringstream iss1(T[0]);
        iss1 >> v;
        sengetsu[v][c]++;
    }
    for (int i = 0; i < 99999; ++i)
    {
        if (sengetsu[i][0] >= 1 && sengetsu[i][1] >= 1)
        {
            cout << i << " " << sengetsu[i][0] + sengetsu[i][1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2968
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...)
#endif


struct OP{
        int y1;
        int x1;
        int y2;
        int x2;
        OP(){}
        OP(int a, int b, int c, int d): y1(a+1), x1(b+1), y2(c+1), x2(d+1){}
        void print() {
            cout << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
        }
    };


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int H, W;
    cin >> H >> W;

    int a[H][W];
    int cnt = 0;
    REP(i, H) REP(j, W) {
        cin >> a[i][j];
        if (a[i][j] & 1) ++cnt;
    }

    vector<OP> ans;

    bool f = false;
    int d = 1;
    int j = 0;
    REP(i, H) {
        if (cnt == 1) break;
        REP(_j, W) {
            if (f) {
                if (j-d > -1 && j-d < W) ans.pb({i, j-d, i, j});
                if(a[i][j] & 1) {
                    f = false;
                    --cnt;
                    if (cnt == 1) break;
                }
            } else {
                if(a[i][j] & 1) {
                    f = true;
                    --cnt;
                }
            }
            j += d;
        }

        d = -d;
        j += d;
        if (f) ans.pb({i, j, i+1, j});
    }

    cout << ans.size() << endl;
    REP(i, ans.size()) {
        ans[i].print();
    }

}


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

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

  if (N == int(ceil(N/1.08)*1.08)) {
    cout << ceil(N/1.08) << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var K = Sarray()[0];
            WriteLine(((K + 1) / 2) * (K / 2));
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28216
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
ll mod=1e9+7;
int main(){ 
    ll n,k,ans=0;
    cin>>n>>k;
    for(int i=k;i<=n+1;i++){
    	ll a=0,b=i-1,c=n-i+1,d=n;
    	ll x=(a+b)*i/2,y=(c+d)*i/2;
    	ans=(ans+y-x+1)%mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
class abcd
{
    public:
    ll day;
    ll vas;
};
bool fun1(abcd x,abcd y)
{
    return x.vas<y.vas;
}
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n;
    cin>>n;
    ll h[n];
    rep(i,0,n)
    {
        cin>>h[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    rep(i,2,n)
    {
        dp[i]=min( ( dp[i-2]+abs(h[i-2]-h[i] )) , (  dp[i-1] + abs( h[i-1] - h[i] )  )  );
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
# クラスかるほう
# 　貪欲に辺ごとにソートをしてとけばいい
W, H = map(int, input().split())
d = []
for i in range(W):
    x = int(input())
    d.append((x, 0))

for j in range(H):
    y = int(input())
    d.append((y, 1))
d.sort()
X = H+1
Y = W+1

ans = 0

for que in d:
    weight, pos = que
    if pos <1:
        ans += X*weight
        Y -= 1
    else:
        ans += Y*weight
        X -= 1
print(ans)

Measured memory_bytes: 70268
#!python3

# input
S = input()
K = int(input())


def main():
    n = 1
    for s in S:
        if s != '1':
            print(int(s))
            return
        if n == K:
            print(1)
            return
        n += 1


if __name__ == "__main__":
    main()


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int n, m; cin >> n >> m;
    vector<P> RL(m);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        RL[i] = P(b, a);
    }

    sort(RL.begin(), RL.end());
    int ans = 0;

    int gx = 0;
    rep(i, m){
        if(gx <= RL[i].second) {
            ans++;
            gx = RL[i].first;
        }
    }


    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
num = int(input())
cards = sorted(list(map(int, input().split())), reverse = True)
alice = 0
bob = 0

if num//2*2 == num:
  for i in range(num//2):
    alice += cards[i*2]
    bob += cards[i*2+1]
else:
  for i in range(num//2):
    alice += cards[i*2]
    bob += cards[i*2+1]
  alice += cards[num-1]

print(alice - bob)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n;
	cin >> n;
	double x = n / 3.0;
	double ans = x * x * x;
	cout << fixed << setprecision(10) << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
void solve(long long K)
{
  cout << a[K - 1] << endl;
}

signed main()
{
  long long K;
  scanf("%lld", &K);
  solve(K);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


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

int main(){
  int a,b,c,x,y;
  long long int ans,cntmin,cntmax;
  cin>>a>>b>>c>>x>>y;
  
  if(a+b>c*2){
    cntmin=min(x,y);
    cntmax=max(x,y);
    ans=c*2*cntmin;
    ans+=a*(x-cntmin)+b*(y-cntmin);
    ans=min(ans,c*2*cntmax);
  }
  else{ans+=a*x+b*y;}

  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

signed main()
{
	ios::sync_with_stdio(false);
	char c;cin>>c;
	if(c>='A'&&c<='Z') cout<<'A'<<endl;
	else cout<<'a'<<endl; 
	return 0;
}

Measured memory_bytes: 3604