akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    VI a(q);
    REP(i,q) a[i] = in() - 1;
    VI p;
    set<int> st;
    REP(i,m) st.insert(i);
    FORR(i,q-1,0){
        if (st.count(a[i])){
            p.push_back(a[i]);
            st.erase(a[i]);
        }
    }
    for (int x : st) p.push_back(x);
    VI idx(m);
    REP(i,m) idx[p[i]] = i;

    // REP(i,m) cout << p[i] << " ";
    // cout << endl;

    int x = m - 1;
    while (x > 0 && p[x - 1] < p[x]) x--;

    VI cnt(m);
    FORR(i,q-1,0){
        int j = idx[a[i]];
        cnt[j] = min(n, cnt[j] + 1);
        if (j) chmin(cnt[j], cnt[j - 1]);
    }
    REP(i,x){
        if (cnt[i] != n){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6648
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 25
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
long long f[MN+5][2][2],ans;
//f[i][0/1][0/1]表示前i个数，前i被前i+1给(进1/不进位)，后i(进1/不进位)给后i-1  的方案数 
int D,s[MN+5],num;
int main(){
    D=read();
    for(int t=D;t;t/=10) s[++num]=t%10;
    for(int len=num;len<=20;++len){
        memset(f,0,sizeof(f));
        f[0][0][0]=1; 
        for(int l=1,r=len,k=1;l<r;++l,--r,++k)
            for(int b1=0;b1<2;++b1) for(int b2=0;b2<2;++b2)
                for(int i=(r==len);i<=9;++i) for(int j=0;j<=9;++j){
                	//从前往后数第l位填i，r位填j 
                    int lnum=i+s[r]+b1,rnum=j+b2+s[l];
                    if(lnum%10!=j||rnum%10!=i) continue;
                    f[k][b1][rnum>=10]+=f[k-1][lnum>=10][b2];
                    // 前k位被进b1，后k进rnum>=10，前k-1位被进lnum>=10,后k-1进b2 
                }
        if(len&1){
            for(int b1=0;b1<2;++b1)
                for(int b2=0;b2<2;++b2)
                    for(int j=(len==1);j<=9;++j){
                        int num=j+b2+s[len+1>>1];
                        if(num/10!=b1||num%10!=j) continue;
                        ans+=f[len/2][b1][b2];
                    }
        }
        else ans+=f[len/2][0][0]+f[len/2][1][1];
    }
    cout<<ans;
    return 0;
}

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

int main() {
  ll a,b,k;
  cin>>a>>b>>k;
  ll vec[2*k];
  for(int i=0;i<k;i++){
    vec[i]=a+i;
    vec[2*k-i-1]=b-i;
  }
  map<ll,int> ma;
  sort(vec,vec+2*k);
  for(int i=0;i<2*k;i++){
    if(vec[i]<a||vec[i]>b){
      continue;
    }
    ma[vec[i]]++;
    if(ma[vec[i]]==1){
      cout<<vec[i]<<endl;
    }
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>

using namespace std;

int N;
// 現在の場所
int now_t, now_x, now_y;
// 次に行く場所
int t, x, y;

int main() {
	int N;
	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", &t, &x, &y);

		// まず最低限必要な時間
		int rest_t = t - now_t - (abs(x - now_x) + abs(y - now_y));
		if (rest_t < 0 || rest_t % 2 == 1) {
			printf("No\n");
			return 0;
		}

		// 更新
		now_t = t;
		now_x = x;
		now_y = y;
	}

	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
def f_enf_enclose_all_ternary_search(ITER=100):
    from math import hypot
    N = int(input())
    Pos = [[int(i) for i in input().split()] for j in range(N)]

    def f(x, y):
        """N 個の点をすべて囲む円のうち，中心が (x, y) で半径が最小の円の半径"""
        return max(hypot(px - x, py - y) for px, py in Pos)

    def g(x):
        left, right = -1000.0, 1000.0
        for _ in range(ITER):
            m1 = (left * 2 + right) / 3
            m2 = (left + right * 2) / 3
            if f(x, m1) > f(x, m2):
                left = m1
            else:
                right = m2
        return f(x, left)

    left, right = -1000.0, 1000.0
    for _ in range(ITER):
        m1 = (left * 2 + right) / 3
        m2 = (left + right * 2) / 3
        if g(m1) > g(m2):
            left = m1
        else:
            right = m2
    return round(g(left), 10)

print(f_enf_enclose_all_ternary_search())

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

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

#define PB push_back

int main(){
	int n, r, t;
	scanf("%d%d%d", &n, &r, &t);
	int p[n];
	REP(i, n) scanf("%d", p+i);
	
	int fil[r], emp[r];
	int x[n];
	int cnt = 0;
	fill(x, x+n, 0);
	fill(fil, fil+r, 0);
	fill(emp, emp+r, 0);
	REP(h, t){
		REP(i, n){
			x[i]+=p[i];
			x[i]%=r;
			if(h>0){
				emp[x[i]]++;
			}
			if(fil[x[i]]==0){
				cnt++;
			}else{
				fil[x[i]]--;
			}
		}
		REP(i, r){
		 	fil[i]+=emp[i];
			emp[i]=0;
		}
	}
	printf("%d\n", cnt);
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
#define PI 3.14159265358979323846

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	ll k;
	cin>>k;
	queue<ll> que;
	FOR(i,1,10)que.push(i);
	while(--k)
	{
		auto t = que.front();que.pop();
		ll b = t%10;
		FOR(i,max(0ll,b-1),min(9ll,b+1)+1)que.push(i+t*10);
	}
	cout<<que.front()<<endl;
	return 0;
}

Measured memory_bytes: 4732
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
   double r,s,c;
   double M_PI = 3.141592653589;
   cin >> r;
   s=r*r*M_PI;
   c=2*r*M_PI;
   printf("%lf %lf\n",s ,c);

}

Measured memory_bytes: 3180
n, m = map(int, input().split())
h = list(map(int, input().split()))
 
edeg = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    edeg[a].append(b)
    edeg[b].append(a)
 
#print(edeg)

ans = 0
for node in range(n):
    good = True
    for neigber in edeg[node]:
        #print("neigber:", neigber)
        if h[node] <= h[neigber]:
            good = False
    if good:
        ans += 1 

print(ans)

Measured memory_bytes: 29428
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	priority_queue<int> q;
	rep(i, N) 
	{
		int tmp;
		cin >> tmp;
		q.push(tmp);
	}
	rep(i, M)
	{
		int M = q.top(); q.pop();
		q.push(M / 2);
	}
	ll ans = 0;
	rep(i, N)
	{
		ans += q.top(); q.pop();
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 892
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] A = in.ii(N);
        Arrays.sort(A);
        long t = 0;
        int d = N - 1;
        int x = A[N - 1];
        int min = Integer.MAX_VALUE;
        long ans = 0;
        for (int i = 0, j = N - 1; i < N - 1; i++) {
            j += i % 2 == 0 ? -d : d;
            int v = Math.abs(A[j] - x);
            d--;
            min = Math.min(min, v);
            ans += v;
            x = A[j];
        }
        int v = Math.abs(A[N - 1] - x);
        min = Math.min(min, v);
        ans += v - min;

        d = N - 1;
        x = A[0];
        long ans2 = 0;
        for (int i = 0, j = 0; i < N - 1; i++) {
            j += i % 2 == 0 ? d : -d;
            v = Math.abs(A[j] - x);
            d--;
            min = Math.min(min, v);
            ans2 += v;
            x = A[j];
        }
        v = Math.abs(A[0] - x);
        min = Math.min(min, v);
        ans2 += v - min;

        out.println(Math.max(ans, ans2));
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

max_l = k-a[-1]+a[0]


for i in range(1,n):
    if a[i] - a[i-1] > max_l:
        max_l = a[i] - a[i-1]



print(k-max_l)

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

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

#define St first
#define Nd second
#define Pb push_back
#define Mp make_pair
#define print_pair(p) cout<<p.St<<" "<<p.Nd
#define endl "\n"

#define REP(i,a,b) for(int i = a; i <= b; i++)
#define REV(i,a,b) for(int i = a; i >= b; i--)

#define AritSum(a,d,n) ((n)*(2*(a)+((n)-1)*(d)))/2
#define Log(base, num) log2(num)/log2(base)


// ************* MAIN *******************

ll N, A[100001],suffix[1000005], Max[1000001];
ll solve() {
    cin >>N;
    REP(i,0,N) cin>>A[i];
    suffix[N+1]=0;
    REV(i,N,0) suffix[i] = suffix[i+1] + A[i];
    // REP(i,0,N) {
    //     if (i > 27) Max[i] = INT_MAX;
    //     else Max[i] = min((1<<i), INT_MAX);
    // }
    if (A[0] > 0) {
        if (N==0 && A[0]==1) return 1;
        if (N==0 && A[0] > 1) return -1;
        if (N>0) return -1;
    }
    ll avai = 1, ans = 1;
    REP(i,1,N) { 
        if (A[i] > avai*2) return -1;
        ll desi = min(suffix[i], avai*2);
        ans+=desi;
        avai = desi - A[i];
    }
    return ans;
}
/*
g++ -std=c++14 -Wall -Wextra -O2 Test.cpp -o Test
*/
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T=1;
    // cin>>T;
    for (int t = 1; t <= T; t++) {
        // cout << "Case #" << t << ": ";
        // solve();
        cout << solve() << endl;
    }
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// 任意の個数の変数をスペース区切りで出力します
void dump() {
  cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) != 0)
    cout << " ";
  dump(std::move(tail)...);
}

// ====================================================================

int main() {
  int n, a;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a;
    mp[a]++;
  }

  int ans = 0;
  for (auto x : mp) {
    if (x.second < x.first)
      ans += x.second;
    else
      ans += x.second - x.first;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

signed main(){
	int k,s;
	cin>>k>>s;
	int ans=0;
	rep(i,k+1){
		rep(j,k+1){
			int z=s-i-j;
			if(z>=0&&z<=k)++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]


total = sum(a)
num = 0

if total == x:
    num = N
elif total < x:
    num = N -1
else:
    a.sort()
    cum = 0
    for i, aa in enumerate(a):
        cum += aa
        if cum > x:
            num = i
            break

print(num)


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long

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

    int x; cin >> x;
    if(x == 2){
        cout << 2 << endl;
        return 0;
    }

    for(;;x ++){
        int i;
        for(i = 2;i <= x/2;i ++){
            if(x % i == 0){
                break;
            }
        }

        if(i == x/2 +1){
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int M, D;
	scanf("%d %d", &M, &D);
	if (M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M == 10 || M == 12) {
		if (D == 31) printf("1");
		else printf("0");
	} else if (M == 2) {
		if (D == 28) printf("1");
		else printf("0");
	} else if (D == 30) printf("1");
	else printf("0");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	REP(i,3){
		if(s[i] == s[i + 1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
int n,m,k;
int main()
{
    fastio;
    deque<ll>dq;
    cin>>k;
    if(k<=9)
    {
        cout<<k<<endl;
        return 0;
    }
    for(int i=1;i<=9;i++)dq.pb(i);
    int cnt = 9;
    while(!dq.empty())
    {
        ll tp = dq.front();
        dq.pop_front();
        int lst = tp%10;
        for(int i=0;i<10;i++)
        {
            if(abs(i-lst)<=1)
            {
                ll num = tp*10 + i;
                dq.push_back(num);
                cnt++;
                if(cnt==k)
                {
                    cout<<num<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
	int i,x,y;
	i=0;
	while(i<3000)
	{
		i++;
		scanf("%d %d",&x,&y);
		(((x>0)&&(x<10000))&&((y>=0)&&(y<=10000)));
		if((x==0)&&(y==0))break;
		if(x<=y)
		{
			printf("%d %d\n",x,y);
		}
		else
		{
			printf("%d %d\n",y,x);
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 600
N = int(input())
A = list(map(int, input().split()))

alice = 0
bob = 0

A_rev = sorted(A, reverse=True)

while True:
    if len(A_rev) != 0:
        alice += A_rev.pop(0)
    
    if len(A_rev) != 0:
        bob += A_rev.pop(0)
    
    if len(A_rev) == 0:
       break
 
print(alice - bob)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int a[10], p = 0, ba = 0;
		fill(a, a + 10, 0);
		string b;
		cin >> b;
		for (int i = 0; i < b.length(); i++) {
			switch (b[i]) {
			case 'M':
				a[p]++;
				p++;
				break;
			case 'S':
				ba += (a[p] + 1);
				a[p] = 0;
				p++;
				break;
			case 'L':
				a[p]++;
				a[p] += ba;
				ba = 0;
				p++;
				break;
			}
			if (p >= n) p = 0;
		}
		sort(a, a + n);
		for (int i = 0; i < n; i++) {
			if (i == 0)
				cout << a[i];
			else
				cout << " " << a[i];
		}
		cout << " " << ba << endl;
	}
}

Measured memory_bytes: 3124
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, m, x;
	vector<int> vec;
	cin >> n >> m >> x;
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		vec.push_back(a);
	}
	int under = 0, top = 0;
	for (int i = 1; i < n; ++i) {
		if (i == x) continue;
		for (int j = 0; j < m; ++j) {
			if (i == vec[j]) {
				if (i < x) under += 1;
				if (i > x) top += 1;
			}
		}
	}
	if (under <= top) cout << under << endl;
	else cout << top << endl;
	return 0;
}

Measured memory_bytes: 256
#%%
s = list(input())
k = int(input())

t1 = 0
t2 = 0
if s[0] == s[-1]:
    for i in range(len(s)):
        if s[i] == s[0]:
            t1 += 1
        else:
            break
    s = s[::-1]
    for i in range(len(s)):
        if s[i] == s[0]:
            t2 += 1
        else:
            break
    if len(set(s)) == 1:
        t = len(s)
    s = s[::-1]
    t = t1 + t2

t = t1 + t2
ss = t//2
ans = 0
tmp = 0

for i in range(t1, len(s)-t2):
    #print(i)
    #print(t1, len(s)-t2-1)
    if i == t1:
        tmp = 1
    elif t1 < i < len(s)-t2-1:
        if s[i] == s[i-1]:
            tmp += 1
            #print("tmp", tmp)
        else:
            ans += tmp//2
            tmp = 1
    else:
        if s[i] == s[i-1]:
            tmp += 1
            ans += tmp //2
        else:
            ans += tmp //2
            tmp = 1

if len(set(s)) == 1:
    anser = len(s) * k //2
    print(anser)
else:
    anser = ss*(k-1) + ans * k + t1//2 + t2//2
    print(anser)
    #print(ss, ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    for(ll i=0; i<n; i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end(), greater<ll>());
    ll ans = 0;
    ll check = 1;
    for(ll i=0; i<n; i++){
        if(check <= k){
            check += 1;
        }else{
            ans += h[i];
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

ll modexp(ll b, ll e) {
    if (e == 0) return 1;
    else return (e & 1 ? b : 1) * modexp(b * b % MOD, e / 2) % MOD;
}

ll FMOD(ll x) {
    return (x % MOD + MOD) % MOD;
}

int main() {
    int n; scanf("%d", &n);
    ll comple = 2 * modexp(9, n) - modexp(8, n);
    printf("%lld\n", FMOD(modexp(10, n) - comple));
    return 0;
}


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


int main() {
  int a[4];
  memset(a,0,sizeof(a));
  for(int i=0;i<2;i++ )
  {
    int x;
    cin>>x;
    a[x]++;
  }
  for(int i=1;i<=3;i++)
  {
if(!a[i])
{
  cout<<i<<endl;
}
  }



}

Measured memory_bytes: 256
from itertools import repeat, chain

a, b = map(int, input().split())

xs,ys,zs = (1,3,5,7,8,10,12), (4,6,9,11), (2,)
d = dict(chain(zip(xs, repeat(0)), zip(ys, repeat(1)), zip(zs, repeat(2))))

print('Yes' if d[a] == d[b] else 'No')

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 0;
	if (*ci == '-') {
		pn = 1;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	if (pn) tmp = -tmp;
	return tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	ll mae = 1e18;
	int kazu = 0;
	rep(i, N + 1) {
		if (mae != A[i]) {
			mae = A[i];
			kazu = 0;
		}
		kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4848
//
// Created by 10034 on 2020/7/30.
//

#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
typedef pair<int,int> PII;

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(){
    int n,m,k,x1,x2,y1,y2;
    cin>>n>>m>>k;
    vector<string> g(n);
    vector<vector<int>> d(n,vector<int>(m,1e9));
    queue<PII> q;
    cin>>x1>>y1>>x2>>y2;
    x1--,y1--,x2--,y2--;
    d[x1][y1]=0;
    for(int i=0;i<n;++i){
        cin>>g[i];
    }
    q.push({x1,y1});
    while(q.size()){
        int xx=q.front().first,yy=q.front().second;
        q.pop();
        for(int i=0;i<4;++i){
            for(int j=1;j<=k;++j) {
                int nx = xx + dx[i] * j, ny = yy + dy[i] * j;
                if (nx < 0 || ny < 0 || nx >=n || ny >=m ||g[nx][ny]=='@'| d[nx][ny] <= d[xx][yy]) break;
                if(d[nx][ny]>d[xx][yy]+1) {
                    d[nx][ny] = d[xx][yy] + 1;
                    q.push({nx, ny});
                }
                if(nx==x2&&ny==y2) {
                    cout<<d[nx][ny]<<endl;
                    return 0;
                }
            }
        }
    }
    puts("-1");

    return 0;
}

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

using namespace std;

int k;
long long ssum;

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

int main(void)
{
	scanf("%d", &k);
	
	for(int i = 1 ; i <= k ; i++)
	{
		for(int j = 1 ; j <= k ; j++)
		{
			for(int o = 1 ; o <= k ; o++)
				ssum += gc(gc(i, j), o);
		}
	}
	
	printf("%lld", ssum);
	return 0;
}

Measured memory_bytes: 3828
if __name__ == '__main__':
    s = input()
    N = len(s)
    res = 0
    for bit in range(1 << N - 1):
        tmp = 0
        for i in range(N - 1):
            tmp *= 10
            tmp += int(s[i])
            if bit & (1 << i):
                res += tmp
                tmp = 0
        tmp *= 10
        tmp += int(s[-1])
        res += tmp
    
    print(res)

Measured memory_bytes: 9120
N = int(input())
L = list(map(int, input().split()))

ans = 0

for i in range(N-2):
  for j in range(N-2-i):
    for k in range(N-2-i-j):
      J = 1 + i + j
      K = 2 + i + j + k
      L_list = [L[i], L[J], L[K]]
      L_list.sort()
      
      if L[i] == L[J] or L[J] == L[K] or L[K] == L[i]:
        pass
      else:
        if L_list[0] + L_list[1] > L_list[2]:
          ans += 1
          
print(ans)

Measured memory_bytes: 9136
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

#define MAX 151
#define INF 1e9

struct P{
  int x, y, d;
  P(int x, int y, int d){
    this->x = x;
    this->y = y;
    this->d = d;
  }
};

int t, sx, sy;
bool impossible[MAX][MAX];
int dist[MAX][MAX];
const int dx[] = {-1,0,0,-1,1,1};
const int dy[] = {-1,-1,1,0,0,1};

int bfs(int x, int y){
  bool visited[MAX][MAX];
  memset(visited,false,sizeof(visited));
  fill(dist[0],dist[MAX],INF);

  queue<P> que;
  que.push(P(x,y,0));
  dist[x][y] = 0;

  while(!que.empty()){
    P p = que.front(); que.pop();

    if(impossible[p.x][p.y] || p.d > t || 
       visited[p.x][p.y]){
      continue;
    }
    visited[p.x][p.y] = true;

    for(int i = 0 ; i < 6 ; i++){
      int nx = p.x + dx[i];
      int ny = p.y + dy[i];
      
      if(impossible[nx][ny] || dist[nx][ny] != INF){
        continue;
      }

      dist[nx][ny] = dist[p.x][p.y] + 1;
      que.push(P(nx,ny,dist[nx][ny]));
    }
  }

  int res = 0;
  for(int i = 0 ; i < MAX ; i++){
    for(int j = 0 ; j < MAX ; j++){
      if(dist[i][j] <= t){
        res++;
      }
    }
  }
  return res;
}

int main(){
  int n, x, y;

  while(cin >> t >> n , (t | n)){
    memset(impossible,false,sizeof(impossible));
    for(int i = 0 ; i < n ; i++){
      cin >> x >> y;
      x += 75, y += 75;
      impossible[x][y] = true;
    }
    cin >> sx >> sy;
    cout << bfs(sx+75, sy+75) << endl;
  }

  return 0;
}

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

using namespace std;

struct edge {
    int to;
    int cost;
    edge(int a, int b) : to(a), cost(b) {}
};


vector<int> dist;
vector<vector<edge>> e;
int N;

int dfs1(int p, int par = -1)
{
    int& res = dist[p];
    for (auto x : e[p]) {
        if (x.to == par) continue;
        res = max(res, x.cost + dfs1(x.to, p));
    }
    return res;
}

int dfs2(int p, int d_par = 0, int par = -1)
{
    vector<pair<int, int>> d;
    d.emplace_back(0, -1);
    for (auto x : e[p]) {
        if (x.to == par) d.emplace_back(d_par + x.cost, x.to);
        else d.emplace_back(dist[x.to] + x.cost, x.to);
    }
    sort(d.rbegin(), d.rend());
    int res = d[0].first + d[1].first;
    for (auto x : e[p]) {
        if (x.to == par) continue;
        res = max(res, dfs2(x.to, d[x.to == d[0].second].first, p));
    }
    return res;
}

int main()
{
    cin >> N;
    dist.resize(N, 0);
    e.resize(N);
    for (int i = 0; i < N-1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        e[s].emplace_back(t, w);
        e[t].emplace_back(s, w);
    }
    dfs1(N / 2);
    cout << dfs2(N / 2) << endl;
}


Measured memory_bytes: 18060
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/11/20 21:59:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int r; cin>>r;
  cout << r*r << endl;

  return 0;
}


Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 10000000 + 10;
const ll MOD = 998244353;
const ll INF = 1000000010;
const ll LOG = 25;

int fac[N], inv[N], tav[N], mx[N];

int POW(int x, int y){
	int res = 1;
	while (y){
		if (y & 1) res = res * 1ll * x % MOD;
		y >>= 1;
		x = x * 1ll * x % MOD;
	}
	return res;
}

int nCr(int a, int b){
	if (b < 0 || a < 0 || b > a) return 0;
	int res = fac[a];
	res = res * 1ll *inv[b] % MOD;
	res = res * 1ll * inv[a - b] % MOD;
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	fac[0] = tav[0] = 1;
	for (int i = 1; i < N; i++) tav[i] = tav[i - 1] * 2ll % MOD;
	for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * 1ll * i % MOD;
	inv[N - 1] = POW(fac[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; i--) inv[i] = inv[i + 1] * 1ll * (i + 1) % MOD;
	int ans = POW(3, n);
	for (int i = n / 2 + 1; i <= n; i++){
		int res = nCr(n, i) * 1ll * tav[n - i] % MOD;
		ans -= res * 2ll % MOD;
		ans %= MOD;
		ans += MOD;
		ans %= MOD;
	}
	cout << ans;
	return 0;	
}


Measured memory_bytes: 120820
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

int h, w;
string s[15];
bool used[15];
vector<P> vec;
multiset<string> S;

bool check2()
{
	multiset<string> T;
	for(auto it = S.begin(); it != S.end(); it++) T.insert(*it);
	while(T.size()){
		string p = *T.begin();
		string q = p;
		reverse(q.begin(), q.end());
		if(p == q && T.count(q) < 2) return false;
		if(p != q && T.count(q) == 0) return false;
		T.erase(T.begin());
		T.erase(T.lower_bound(q));
	}
	return true;
}

bool check()
{
	S.clear();
	string t[15];
	for(int i = 0; i < w; i++){
		for(int j = 0; j < vec.size(); j++) t[i] += s[vec[j].first][i];
		for(int j = (int)vec.size()-1; j >= 0; j--) t[i] += s[vec[j].second][i];
		S.insert(t[i]);
	}
	if(w % 2){
		for(int i = 0; i < w; i++){
			S.insert(t[i]);
			if(check2()) return true;
			S.erase(S.lower_bound(t[i]));
		}
		return false;
	}
	return check2();
}

bool dfs()
{
	int x = -1;
	for(int i = 0; i < h; i++){
		if(!used[i]){
			x = i;
			break;
		}
	}
	if(x != -1){
		for(int i = x+1; i < h; i++){
			if(used[i]) continue;
			used[x] = used[i] = true;
			vec.push_back(make_pair(x, i));
			if(dfs()) return true;
			vec.pop_back();
			used[x] = used[i] = false;
		}
		return false;
	}
	return check();
}

int main(void)
{
	cin >> h >> w;
	for(int i = 0; i < h; i++) cin >> s[i];
	
	if(h % 2){
		for(int i = 0; i < h; i++){
			vec.push_back(make_pair(i, i));
			used[i] = true;
			if(dfs()){
				cout << "YES" << endl;
				return 0;
			}
			vec.pop_back();
			used[i] = false;
		}
	}
	else{
		if(dfs()){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#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 MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
const int MAXN = 1e5 + 5;

int main()
{
	zapp;
	ll n, i;
	cin >> n;
	vl a(n);
	for (i = 0; i < n; i++)
		cin >> a[i];
	ll mxt = 0;
	ll sum = 0;
	for (i = 0; i < n; i++) {
		if (a[i] >= mxt)
			mxt = a[i];
		else
			sum += mxt - a[i];
	}
	cout << sum;

	return 0;
}



Measured memory_bytes: 4760
using System;
public class Hello{
    public static void Main(){
        int ramen = 700;
        string s = Console.ReadLine();
        for(int i = 0;i < s.Length;i++){
            if(s[i] == 'o'){
                ramen += 100;
            }
        }
        Console.WriteLine(ramen);
    }
}


Measured memory_bytes: 11092
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1];
		Console.WriteLine(Enumerable.Range(k + 1, n - k).Sum(b => (long)n / b * (b - k) + Math.Max(0, n % b - (k == 0 ? 0 : k - 1))));
	}
}


Measured memory_bytes: 13396
import math
result = []

while True:
  n = int(input())
  
  if n == 0:
    break
  
  s = list(int(x) for x in input().split())
  a2 = 0
  m = sum(s) / len(s)
  for x in s:
    a2 += (x - m) ** 2 / n
  result.append(math.sqrt(a2))

for x in result:
  print(x)


Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#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 ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v)-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

    FAST
//	PRECISE


ll x,y;
cin>>x>>y;
if(y%2!=0)
	cout<<"No";
else{
	y=y/2;
	if(y-x>=0&&2*x-y>=0)
		cout<<"Yes";
	else
		cout<<"No";
}


return 0;
 }



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

int main() {
    int32_t a, b, c;

    cin >> a >> b >> c;

    if (a == b && b == c) {
        if (a % 2 == 0) {
            cout << "-1" << endl;
        } else {
            cout << "0" << endl;
        }
        return 0;
    }

    int32_t a2, b2, c2;
    int32_t count = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        a2 = (b + c) / 2;
        b2 = (c + a) / 2;
        c2 = (a + b) / 2;
        a = a2;
        b = b2;
        c = c2;
        count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a); i >=(b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod1=1000000007;
ll mod2=67280421310721;
ll mod3=998244353;
ll INF=1e18;

ll binpow1(ll a,ll b){
    ll res=1;
    while (b>0){
        if (b&1)
        res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

ll binpow2(ll a,ll b,ll m){
    a%=m;
    ll res=1;
    while (b>0){
        if (b & 1)
        res=res*a%m;
        a=a*a%m;
        b>>=1;
    }
    return res;
}

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

map<ll,ll> fact(ll n) {
    map<ll,ll> factorization;ll c=0;
    while (n % 2 == 0) {
        c++;
        n /= 2;
    }
    if(c>0)
    {
        factorization.insert({2,c});
    }c=0;
    for (ll d = 3; d * d <= n; d += 2) {
        while (n % d == 0) {
            c++;
            n /= d;
        }
        if(c>0)
    {
        factorization.insert({d,c});
    }c=0;
    }
    if (n > 1)
       {
           factorization.insert({n,1});
       }
    return factorization;
}
 
int main()
{ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll x;
    cin>>x;
    cout<<(1-x);
    
    
    
 
	return 0;
}













Measured memory_bytes: 3600
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	vi v(n - 1);
	for (int i = 0; i < n - 1; ++i) {
		cin >> v[i];
	}

	ll sol = 0;
	sol += v[0]; sol += v[n - 2];

	for (int i = 0; i < n - 2; ++i) {
		sol += min(v[i], v[i + 1]);
	}

	cout << sol << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
      int array[] = {A,B,C};
      Arrays.sort(array);
      System.out.println(array[0]*array[1]/2);
      
    }
}

Measured memory_bytes: 35740
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 07, 2020 1:01 PM
 *    Problem Name  : A - Frog 1
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/dp/tasks/dp_a
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int>v(n);

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

    int dp[n+1] = {0};

    dp[1] = abs( v[1] - v[0]);

    for(int i=2; i<n; i++){
        dp[i] = min((abs(v[i]-v[i-1])+ dp[i-1]) , (abs(v[i]-v[i-2])+ dp[i-2]));
    }
    
    cout << dp[n-1] << endl;
    return 0 ;
}


Measured memory_bytes: 4024
#include <stdio.h>
int main(){
	int n, i, s=0;
	scanf("%d", &n);
	i = n;
	while (i){
		s += i%10;
		i /= 10;
	}
	if (n%s){
		printf("No\n");
	
	}
	else{
		printf("Yes\n");

	}
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
long int N,K,A[101][100001],a[101];

long int dp(long int n,long int m)
{
  long int temp;
  long int s;
  
  if(A[n][m]!=-1)
  {
    return A[n][m];
  }
  else
  {
    
    temp=0;
    if(m>0)
    {
      temp+=dp(n,m-1);
    }
    if(n>1)
    {
      temp+=dp(n-1,m);
      if(m-1-a[n]>=0)
      {
        temp-=dp(n-1,m-1-a[n]);
        if(temp<0)
        {
          temp+=1000000007;
        }
      }
    }
      
    
  }
  

  temp=temp%1000000007;
  A[n][m]=temp;
  
  return temp;
  
}
 
int main()
{
  
  long int i,j;
  
  scanf("%ld %ld",&N,&K);
  

  for(i=1;i<N+1;i++)
  {
    scanf("%ld",&a[i]);
  }
  
  for(i=0;i<N+1;i++)
  {
    for(j=0;j<K+1;j++)
    {
      A[i][j]=-1;
    }
  }

  for(j=0;j<K+1;j++)
      {
        if(j<=a[1])
        {
          A[1][j]=1;
        }
        else
        {
          A[1][j]=0;
        }
      }
  

   printf("%ld",dp(N,K));

  
  return 0;
}


Measured memory_bytes: 83712
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    input! {
        n: usize1,
        lis: [(u64,u64,u64);n]
    }
    let mut v: Vec<u64> = Vec::new();
    for i in 0..n+1 {
        let mut t = 0;
        for j in i..n {
            let (c,s,f) = lis[j];
            if t < s {
                t = s;
            } else if t % f == 0 {
                ;
            } else {
                t = t + f - t % f;
            }
            t += c;
        }
        v.push(t);
    }
    for e in v {
        println!("{}", e);
    }
}


Measured memory_bytes: 4352
s=input().split()
l=[int(s[0]),int(s[1])]
k=int(s[2])
for i in range(k):
  ind=i%2
  l[ind]-=l[ind]%2
  l[(ind+1)%2]+=l[ind]//2
  l[ind]//=2
print(l[0],end=" ")
print(l[1])

Measured memory_bytes: 38256
N,K=map(int,input().split())
d=[]
A=[]
for i in range(K):
	d.append(input())
	arr=input().split()
	A.append(arr)
B=[]
for i in range(len(A)):
	for j in range(len(A[i])):
		B.append(int(A[i][j]))
count=0
for i in range(1,N+1):
	if i not in B:
		count+=1
print(count)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N+1);
  for(int i=0;i<N;i++) {
    cin>>A.at(i);
  }
  A.at(N)=0;
  
  sort(A.begin(),A.end());
  
  int Alice=0,Bob=0;
  
  for(int i=N;i>0;i-=2){
    Alice+=A.at(i);
    Bob+=A.at(i-1);
  }
  
  cout<<Alice-Bob<<endl;
  return 0;
}

Measured memory_bytes: 256
//team04 lyt

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
//#include <io.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

char s[200005];
char ss[200005];
int las[100];
int dep[200005];
int pre[26][200005];

int main()
{
    while(scanf("%s",ss)==1)
    {
        memset(las,-1,sizeof(las));
        memset(dep,-1,sizeof(dep));
        memset(pre,-1,sizeof(pre));
        int len=strlen(ss);
        for(int i=0;i<len;i++)
            s[i]=ss[len-i-1];
        for(int i=0;i<len;i++)
        {
            for(int j=0;j<26;j++)
            {
                pre[j][i]=las[j];
                if(las[j]==-1)
                    dep[i]=0;
                else if(dep[i]==-1||dep[i]>dep[las[j]]+1)
                    dep[i]=dep[las[j]]+1;
            }
            las[s[i]-'a']=i;
        }

        for(int j=0;j<26;j++)
        {
            pre[j][len]=las[j];
            if(las[j]==-1)
                dep[len]=0;
            else if(dep[len]==-1||dep[len]>dep[las[j]]+1)
                dep[len]=dep[las[j]]+1;
        }

        int pos=len;
        int mark;
        while(true)
        {
            int mxdep=1e6;
            for(int i=0;i<26;i++)
            {
                if(pre[i][pos]==-1)
                {
                    mark=i;
                    pos=-1;
                    break;
                }
                if(dep[pre[i][pos]]<mxdep)
                {
                    mark=i;
                    mxdep=dep[pre[i][pos]];
                }
            }
            printf("%c",mark+'a');
            if(pos==-1)
                break;
            pos=pre[mark][pos];
        }
        printf("\n");


    }

    return 0;
}


Measured memory_bytes: 21760
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

void compress(vector<int> &v){
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
}

inline int index(const vector<int> &v, int x){
	return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main(){
	int n, r;
	while(scanf("%d%d", &n, &r), n){
		vector<int> x1(n), y1(n), x2(n), y2(n);
		vector<int> xs(2), ys(2);
		xs.reserve(2 * n + 2);
		ys.reserve(2 * n + 2);
		xs[0] = ys[0] = -100000;
		xs[1] = ys[1] = 100000;

		for(int i = 0; i < n; ++i){
			scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
			xs.push_back(x1[i]);
			xs.push_back(x2[i]);
			ys.push_back(y1[i]);
			ys.push_back(y2[i]);
		}

		compress(xs);
		compress(ys);

		vector<vector<int> > incs(xs.size()), decs = incs;
		for(int i = 0; i < n; ++i){
			int xi1 = index(xs, x1[i]);
			int xi2 = index(xs, x2[i]);
			int yi1 = index(ys, y1[i]);
			int yi2 = index(ys, y2[i]);

			incs[xi1].push_back(yi1);
			decs[xi2].push_back(yi1);
			decs[xi1].push_back(yi2);
			incs[xi2].push_back(yi2);
		}

		int area = 0, len = 0;

		vector<int> prev(ys.size()), now = prev, next = prev;
		for(int i = 0; i + 1 < xs.size(); ++i){
			fill(next.begin(), next.end(), 0);
			for(int j = 0; j < incs[i+1].size(); ++j){
				++next[incs[i+1][j]];
			}
			for(int j = 0; j < decs[i+1].size(); ++j){
				--next[decs[i+1][j]];
			}
			for(int j = 1; j < next.size(); ++j){
				next[j] += next[j-1];
			}
			for(int j = 0; j < next.size(); ++j){
				next[j] += now[j];
			}

			for(int j = 1; j + 1 < ys.size(); ++j){
				if(now[j] == 0) continue;
				
				int dx = xs[i+1] - xs[i];
				int dy = ys[j+1] - ys[j];
				area += dx * dy;
				
				if(prev[j] == 0) len += dy;
				if(next[j] == 0) len += dy;
				if(now[j-1] == 0) len += dx;
				if(now[j+1] == 0) len += dx;
			}
			
			prev.swap(now);
			now.swap(next);
		}

		printf("%d\n", area);
		if(r == 2) printf("%d\n", len);
	}
}

Measured memory_bytes: 2232