akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

long double a,b,c;

signed main() {
    cin >> a >> b >> c;
    if (c-a-b < 0) yn(false)
    else if (4*a*b < (c-a-b)*(c-a-b)) yn(true)
    else yn(false)
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t n, a, b;
    cin >> n >> a >> b;

    if (a < b)
    {
        swap(a, b);
    }

    if ((a - b) % 2 == 0)
    {
        cout << (a - b) / 2 << endl;
    }
    else
    {
        // b 回勝つと、b -> 1, a -> a - b, (a - b - 1) / 2
        auto cand1 = b + (a - b - 1) / 2;
        auto cand2 = (n - a) + 1 + (a - b - 1) / 2;
        cout << min(cand1, cand2) << endl;
        // (n - a) 回負けると、 a -> n, b -> b + (n - a), (n - (b + (n - a)) - 1) / 2
        // = (a - b - 1) / 2;
        // (n - a) + + ()
    }
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数

N,K,S = imn()
cnt = 0
A = []
for i in range(N):
    
    cnt += 1
    if cnt <= K: 
        A.append(str(S))
    else:
        if S != 10**9:
            A.append(str(10**9)) 
        else:
            A.append(str(1))
print(join(A, ' '))



Measured memory_bytes: 15536
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pb push_back
ll n,m;
ll p[200006] , sz[200005];
ll u[200005], v[200005];
ll ans[200005];
ll fs(ll x)
{
        return p[x]==x ? p[x] : p[x] = fs(p[x]);
}
bool ms(ll x,ll y)
{
        x = fs(x);
        y = fs(y);
        if(x==y) return false;
        sz[x] += sz[y]; sz[y] = 0;
        p[y] = x;
        return true;
}
int main()
{
        cin >> n >> m;
        for(ll i=1;i<=n;i++) {
                p[i]=i;
                sz[i]=1;
        }
        for(ll i=1;i<=m;i++) {
                cin >> u[i] >> v[i];
        }
        ans[m] = n*(n-1)/2;
        ll tp=0;
        for(ll i=m-1;i>=1;i--) {
                ll A = sz[fs(u[i+1])];
                ll B = sz[fs(v[i+1])];
                if(ms(u[i+1] , v[i+1])) {
                        ans[i] = ans[i+1] - A*B;
                }else ans[i] = ans[i+1];

        }
        for(ll i=1;i<=m;i++) cout << ans[i] << "\n";
        return 0;
}


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


int main()
{

    ll n,cnt=0;
    bool chk=false;
    cin>>n;
    ll arr[n+1];
    set<ll>s;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(arr[i]%2==0)
        {
            if(arr[i]%3==0 || arr[i]%5==0)
                chk= true;
            else
                cnt++;
        }

    }
    if(cnt == 0)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;



}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n, m;
		n = scan.nextInt();
		m = scan.nextInt();
		boolean canMake = true;
		int[] xxx = new int[3];
		for(int i = 0; i < 3; i++) {
			xxx[i] = -1;
		}
		for(int i = 0; i < m; i++) {
			int s = scan.nextInt() - 1;
			int c = scan.nextInt();

			if(xxx[s] == -1) {
				xxx[s] = c;
			} else {
				if(xxx[s] != c) canMake = false;
			}
		}
		if(xxx[0] == 0 && n > 1) canMake = false;
		if(xxx[0] == -1 && n > 1) xxx[0] = 1;
		if(canMake) {
			for(int i = 0; i < n; i++) {
				if(xxx[i] == -1) xxx[i] = 0;
				System.out.print(xxx[i]);
			}
		} else {
			System.out.print(-1);
		}
		System.out.println();
		scan.close();

	}

}


Measured memory_bytes: 22608
#問題 C
N=int(input())
ha,hb,hc = map(int,input().split())
# print(ha,hb,hc)
for i in range(1,N):
    a,b,c=map(int,input().split())
    ha,hb,hc = max(a+hb,a+hc),max(b+ha,b+hc),max(c+hb,c+ha)
#     hb = max(b+ha,b+hc)
#     hc = max(c+hb,c+ha)
#     print("tmpmax",ha,hb,hc)
hap=max(max(ha,hb),hc)
print(hap)
#     x,y,z = map(int,input().split())
#     print(x,y,z)



Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    vector<int> d(n);
    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        d[i]=a;
    }
    sort(d.begin(),d.end());
    printf("%d",d[n/2]-d[n/2-1]);
    
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

ll dp[51][51][2510];

int main(){
    ll N,A;
    cin>>N>>A;
    vector<ll> x(N);
    REP(i,N) cin>>x[i];
    
    REP(i,51){
        REP(j,51){
            REP(k,2510){
                dp[i][j][k]=0;
                
            }
            
        }
    }

    dp[0][0][0]=1;

    REP(i,N){
        REP(j,i+1){
            REP(k,2510){
                if(k+x[i]>2500) continue;
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                dp[i+1][j][k]+=dp[i][j][k];
            } 
        }
    }

    ll ans=0;
    REP2(j,1,N+1){
        REP2(k,1,2510){
            if(k==A*j){
                ans+=dp[N][j][k];
            }
        } 
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 54588
N = int(input())
A = list(map(int, input().split()))
B = sorted(set(A))

if len(B) == 1 and B[0] == 0:
    print('Yes')
    exit()

if N % 3 == 0:
    if len(B) == 2 and A.count(0) == N // 3:
        print('Yes')
        exit()
    if len(B) == 3 and A.count(B[0]) == A.count(B[1]) == A.count(B[2]):
        if B[0] ^ B[1] ^ B[2] == 0:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 14212
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 50 + 3;
const int max_len = 100 + 3;

char name[maxn][max_len];
int n, period[maxn];
char bufname[max_len];

inline bool is_equal(int idx) {
  if (strlen(name[idx] + 1) != strlen(bufname + 1)) return false;
  for (int i = 1; i <= strlen(name[idx] + 1); i++)
    if (bufname[i] != name[idx][i]) return false;
  return true;
}

int solve() {
  int ans = 0, idx;
  for (idx = 1; !is_equal(idx); ++idx);
  for (int i = idx + 1; i <= n; i++) ans += period[i];
  return ans;
}

int main() {
  //freopen("input.txt", "r", stdin);
  while (~scanf("%d", &n)) {
    memset(name, 0, sizeof(name));
    memset(bufname, 0, sizeof(bufname));
    for (int i = 1; i <= n; i++)
      scanf("%s%d", name[i] + 1, &period[i]);
    scanf("%s", bufname + 1);
    printf("%d\n", solve());
  }
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,c=0,d=1,n,max=-1,k,ans=0;
    string s,s2;
    cin >> a >> b >> c >> n;
    for(int i=0;i<n;i++){
        if(a>=b&&a>=c)
            a *= 2;
        if(b>=a&&b>=c)
            b *= 2;
        if(c>=a&&c>=b)
            c *= 2;
    }
    cout << a+b+c << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NAB = Sarray();
            var N = NAB[0];
            var A = NAB[1];
            var B = NAB[2];
            var ans = 0L;

            if ((B - A) % 2 == 0)
                ans = (B - A) / 2;
            else
            {
                var down = A + (B - 1 - A) / 2;
                var up = N - B + 1 + (B - (A + 1)) / 2;
                ans = Min(down, up);
            }
            WriteLine(ans);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

count_a = Counter(A)
ans_list = [0] * (N+1)
for k, v in count_a.items():
    ans_list[k] = int(v * (v-1) / 2)

all_sum = sum(ans_list)
for i in range(N):
    print(all_sum - count_a[A[i]] + 1)


Measured memory_bytes: 111268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long count = x/11;
		count*=2;
		long temp = x-x/11*11;
		if (temp>6) {
			count+=2;
		} else if (temp>0) {
			count++;
		}
		System.out.println(count);
	}
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vll A(N); cin >> A;
	vll B(N);
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		if (i & 1) sum -= A[i];
		else sum += A[i];
	}

	B[0] = sum;
	for (int i = 0; i < N-1; i++) {
		B[i+1] = (A[i] - B[i]/2) * 2;
	}
	cout << B << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,a;
  cin >> A >> B;
  for(int i = A;i <= B;i++){
    if(i % 10 == i / 10000 && (i / 10) % 10 == (i / 1000) % 10)
      a++;   
  }
  cout << a << endl;

}

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

int main() {
  string S;
  cin >> S;
  if(S.at(S.size()-1)=='s') cout << S << "es\n";
  else cout << S << "s\n";
  return 0;
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static int solve(int[] a) {
        return Arrays.stream(a).max().getAsInt() - Arrays.stream(a).min().getAsInt();
    }
}

Measured memory_bytes: 26708
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H,W; cin>>H>>W;
	vector<ii> v(H*W);
	int iter=0;
	for (int i=0; i<H; i++)
		for (int j=0; j<W; j++)
			v[iter++]={i,j};
	sort(v.begin(),v.end(),[&](const ii &x, const ii &y) {
		if(x.first!=y.first)
			return x.first<y.first;
		return x.first%2==0 ? x.second<y.second : x.second>y.second;
	});

	int N; cin>>N;
	vector<int> a(N);
	for (int i=0; i<N; i++)
		cin>>a[i];
	vector<vector<int>> grid(H,vector<int>(W));
	iter=0;
	for (int i=0; i<N; i++)
		for (int j=0; j<a[i]; j++)
			grid[v[iter].first][v[iter].second]=i+1, iter++;
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++)
			cout<<grid[i][j]<<" ";
		cout<<"\n";
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc152() {
	ll n;
	cin >> n;

	V p(n);
	rep(i, n) {
		cin >> p[i];
	}

	ll ans = 1;
	ll minv = p[0];
	rep2(i, 1, n) {
		if (p[i] <= minv) {
			minv = p[i];
			ans++;
		}
	}

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

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

	solve_abc152();

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
/* this code is generated by shikhar verma . Dont try to copy it. You may be booked under plagiarism. */
//int numberofPaths(int h,int w,int a,int b);
int main()
{
    ll n,i,len1,h,w,t,cnt=0,cnt1=0,x=1,m,flag=0,k;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==x)
        {
            cnt++;
            x++;
        }
    }
    if(cnt==0)
    {
        cout<<-1;
    }
    else
        cout<<n-cnt;

	return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>
#include<cmath>

int main(){
    int a, b, C;
    const double PI = acos(-1);
    double S, L, h, c, rad;
    scanf("%d %d %d", &a, &b, &C);
    rad = 2*PI*C/360;
    S = a * b * sin(rad)/2;
    c = sqrt(a*a + b*b -2*a*b*cos(rad));
    L = a + b + c;
    h = S * 2 /a;
    printf("%.7lf %.7lf %.7lf", S, L, h);
    
    return 0;
}


Measured memory_bytes: 2868
#include<stdio.h>

int main(void)
{
	int W;
	int H;
	int x;
	int y;
	int r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if ((x - r) >= 0 && (y - r) >= 0 && (x + r) <= W && (y + r) <= H) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 1012
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){

   int N;
   cin >> N;
   cout << LCM(N,2) << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000



void insert(int *,int ,int );

int cnt;

int main(){
  int i,j,n,a[N],m=0,g[N];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  //shellsort
  cnt=0;
  g[0]=1;
  m++;
  for(i=1;n>=(3*g[i-1]+1);i++){
    g[i]=3*g[i-1]+1;
    m++;
  }
  for(i=0;i<m/2;i++){
    j=g[i];
    g[i]=g[m-i-1];
    g[m-i-1]=j;
  }
  //出力
  for(i=0;i<m;i++)
    insert(a,n,g[i]);

  printf("%d\n",m);
  for(i=0;i<m;i++){
    printf("%d",g[i]);
    if(i<m-1)printf(" ");
  }
  printf("\n%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",a[i]);
  
  }

  return 0;
}

void insert(int a[],int n,int g){
  int i,j,v;
  for(i=g;i<n;i++){
    v=a[i];
    j=i-g;
    while(j>=0&&a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;
    }
    a[j+g]=v;
  }
}



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

int main()
{
	int K,N,now,min;
	cin >> K >> N;
	vector<int> A(N),B(N);
	min = K;
	rep(i, N)
	{
		cin >> A[i];
	}
		rep(i, N-1)
	{
		B[i] = A[i + 1] - A[i];
	}
	B[N-1] = A[0] + (K - A[N-1]);
	rep(i, N) {
		now = K - B[i];
		if (min > now)
			min = now;
	}
	cout << min << endl;
}

Measured memory_bytes: 1792
#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 fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define pb push_back
    #define ll long long
    #define ld long double
     
    #define vi vector<int>
    #define vl vector<long>
    #define vll vector<long long>
    #define infd LDBL_MAX
    #define f(i,a,b) for(ll i=a;i<b;i++)
    
    #define ff first
    #define ss second
   
    #define pll pair<ll,ll> 
    #define endl "\n"
    #define ALL(v) v.begin(),v.end()
    #define nl cout<<"\n";
    #define pr(x) cout<<x;
    #define pr1(x) cout<<x<<" ";
    #define pr2(x,y) cout<<x<<" "<<y;
    #define deb printf("*****************************\n");
    #define idk printf("idk idk ! \n");
    #define hi printf("hi ! \n");
    #define bye printf("bye bye ! \n");
    #define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
    #define number_of_set_bits  __builtin_popcountll  
     
  
     
     
    //const ll N=1e6+7;
    ll p=1e9+7;
    //ll fac[N];
     
// taking inpugt with help of string and " "
     /*   string s;
         getline(cin,s);
         vi a=init(s);
         if(a.size()==2)cout<<query_(a[0]+1,a[1]+1)<<endl;
         else update_(a[0]+1,a[1]+1,a[2]);
 
      */
 vi init(string s)
{
    istringstream sin(s);
    int n;
    vi arr;
    while(sin>>n)arr.push_back(n);
    return arr;
}

    ll gcd(ll a, ll b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
    
    ll pow_mod_p(ll a,ll b)
    {
      a=a%p;
      ll res=1;
      while(b>0)
      {
        if(b&1) res=(res*a)%p;
        b=b>>1;
        a=(a*a)%p;
      }
      return res;
    }
     
    inline ll mod_inv(ll x)
    {
      return pow_mod_p(x,p-2);
    }
     
   
     int main() 
    {
        fast
        //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //#endif // ONLINE_JUDGE
        
     
        ll ntc=1;
     //   cin>>ntc;
     
        f(i,1,ntc+1)
        {
          //cout<<"Case #"<<i<<": ";
         
         ll n; cin>>n;
         ll a[200005];
         f(i,0,n)  cin>>a[i];
         ll maxi = a[0]; ll ans = 0;
         for(int i =1; i<n; ++i) {
             if(a[i] < maxi)  ans += (maxi - a[i]);
             maxi = max(maxi,a[i]);
         }
           cout<<ans<<endl;
        }
     
        return 0;
    }

Measured memory_bytes: 5216
#include<iostream>
using namespace std;
int main(){
 int a, b;
 cin >> a >> b;
 if( a < b ){
 cout << "a < b" << endl;
}else if( a > b ){
 cout << "a > b" << endl;
}else{
 cout << "a == b" << endl;
}
return 0;
}

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

int main(){
    double a,b,c,d; cin >> a >> b >> c >> d;
    int e = ceil(c/b), f = ceil(a/d);
    if(e <= f){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main()
{
    int a[30];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int max=a[0],sum=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]>=max)
        {
            sum++;
            max=a[i];
        }
    }
    cout<<sum<<endl;
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;
/*}}}*/


void solve(){

    int n,h;
    cin >> n >> h;

    int tmp, ans = 0;
    rep(i, 0, n) {
        cin >> tmp;
        if(tmp >= h) ++ans;
    }

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

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=a;i<a*b;i++){
		if(i*a%b==c) {
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

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

    int r = 0, sum = 0, ans = 0;
    for (int l = 0; l <= N - K; ++l) {
        while (r - l < K) {
            sum += p[r];
            r++;
        }
        ans = max(ans, sum);
        sum -= p[l];
    }

    printf("%.12lf\n", ans / 2.0);

    return 0;
}


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

const int INFTY = 1000000;
int main () {
  int n;
  cin >> n;
  vector<int> d(n, INFTY);
  vector<vector<int>> al(n+1);
  rep(i,n) {
    int a;
    cin >> a;
    al[i].push_back(a-1);
  }

  queue<int> q;
  q.push(0);
  d[0] = 0;
  int u;
  while(!q.empty()) {
    u = q.front(); q.pop();
    for(int j : al[u]) {
      if(d[j] != INFTY)  continue;
      d[j] = d[u] + 1;
      q.push(j);
    }
  }

  printf("%d\n", d[1] == INFTY ? -1 : d[1]);
  return 0;
}


Measured memory_bytes: 6144
n = int(input())
al = [int(i) for i in input().split()]

total = 1
siki = 10**18
if al.count(0) >= 1:
  print(0)
else:
  for i in al:
    total *= i
    if total > siki:
      print(-1)
      break
  else:
    print(total)

Measured memory_bytes: 21592
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int k; cin >> k;

  int x = 0;
  for(int i = 1; i <= 1e6; i++){
    x = (x * 10 + 7) % k;
    if(x == 0){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 3612
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def check(n,l):
    s=0
    for i in range(len(l)):
        s+=(l[i]-n)*(l[i]-n)
    return s

def solve():
    s=input()
    n=len(s)
    for i in range(n-1):
        if s[i]==s[i+1]:
            print(i+1, i+2)
            return 
    for i in range(n-2):
        if s[i]==s[i+2]:
            print(i+1, i+3)
            return 
    print(-1, -1)
 

for _ in range(1):
    solve()
    


Measured memory_bytes: 9348
n = int(input())
arr=[int(x) for x in input().split()]

if n == 2:
    print(*arr[::-1])
else:
    res = [0 for i in range(n)]
    temp = 0
    for i in range(1,n):
        temp ^= arr[i]^arr[i-1]
        res[i] = temp   #arr[0]^arr(i)
    # print(res)
    allxor = 0
    for e in res:
        allxor ^= e
    first = allxor^arr[0]
    ans = []
    for e in res:
        ans.append(e^first)
    print(*ans)


Measured memory_bytes: 123792
/*  -*- coding: utf-8 -*-
 *
 * 2728.cc: Change a Password
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;
typedef set<ll> sl;

/* global variables */

int ds[MAX_N];

/* subroutines */

/* main */

int main() {
  string s;
  cin >> s;
  int n = s.size();

  ll a = atoll(s.c_str());
  //printf("%0*lld\n", n, a);

  for (int i = 0; i < MAX_N; i++) ds[i] = i;

  sl bs;
  do {
    ll b = 0;
    for (int i = 0; i < n; i++) b = b * 10 + ds[i];
    bs.insert(b);
  } while (next_permutation(ds, ds + MAX_N));
  //printf("%lu\n", bs.size());

  ll tens = 1;
  for (int i = 0; i < n; i++) tens *= 10;

  ll maxdf = -1, maxb = -1;
  for (sl::iterator sit = bs.begin(); sit != bs.end(); sit++) {
    const ll &b = *sit;
    ll ab = abs(a - b);
    ll df = min(ab, tens - ab);
    if (maxdf < df) maxdf = df, maxb = b;
  }

  printf("%0*lld\n", n, maxb);
  return 0;
}

Measured memory_bytes: 173460
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int N;
    cin >> N;
    map<string, int> mp;

    REP(i, N){
        string str;
        cin >> str;
        mp[str]++;
    }

    cout << "AC" << " x " << mp["AC"] << endl;
    cout << "WA" << " x " << mp["WA"] << endl;
    cout << "TLE" << " x " << mp["TLE"] << endl;
    cout << "RE" << " x " << mp["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d){
		cout<<"Left"<<endl;
	}else if(a+b<c+d){
		cout<<"Right"<<endl;
	}else{
		cout<<"Balanced"<<endl;
	}


}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<String>().chars().collect::<Vec<char>>();
    let b = read::<String>().chars().collect::<Vec<char>>();
    let c = read::<String>().chars().collect::<Vec<char>>();
    if *a.last().unwrap() == b[0] && *b.last().unwrap() == c[0] {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
fn main(){
    let k = {
        let s = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            buf.trim_right().to_owned()
        };
        let k: i32 = s.parse().unwrap();
        k
    };
    let a:Vec<i64> = {
        let s = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            buf.trim_right().to_owned()
        };
        let mut ws = s.split_whitespace();
        (0..k).map(|_| {ws.next().unwrap().parse().unwrap()}).collect()
    };
    let mut lb:i64 = 2;
    let mut ub:i64 = 2;
    let mut isok = true;
    for v in a.iter().rev(){
        let tl=(lb+v-1)/v;
        let tu=ub/v;
        if tl>tu{
            isok=false;
            break;
        }
        else{
            lb=tl*v;
            ub=tu*v+v-1;
        }
    }
    if isok{
        println!("{} {}",lb,ub)
    }
    else{
        println!("{}",-1)
    }
    
}


Measured memory_bytes: 8444
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k,x;
    cin >> k >> x;
    if(x-k+1>=-1000000){
        for(int i=x-k+1;i<x+k;i++){
            cout << i << " ";
        }
    }
    else{
        for(int i=-1000000;i<x+k;i++){
            cout << i << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    string t;
    cin >> s >> t;
    string ss(2 * n, 0);
    for (int i = 0; i < n; ++i) {
        ss[2 * i] = s[i];
        ss[2 * i + 1] = t[i];
    }
    cout << ss << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll t[100005], x[100005], y[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	int index;
	int sa;
	bool ok = true;
	if (n == 1) {
		index = t[0] - 0;
		sa = abs(x[0] - 0) + abs(y[0] - 0);
		if (index < sa || (index % 2 != sa % 2)) {
			ok = false;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		index = t[i + 1] - t[i];
		sa = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (index < sa || (index % 2 != sa % 2)) {
			ok = false;
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 2560
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define MOD 1000000007
#define MOD1 998244353
#define endl "\n"
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pairs;
typedef map<int,int> maps;
typedef vector <int> VI;
typedef std::multimap<int, pair<int,int>>::iterator MMIPIterator;
typedef std::map<int, int>::iterator MIIIterator;
double pi = 2 * acos(0.0);

int32_t main()  {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
    
    int t=1,p=0;
    //in>>t;
    while(t--) {
    	int k,a,b;
    	cin>>k>>a>>b;
    	int i=a;
    	bool ans = false;
    	while(i<=b) {
    		if(i%k == 0) {ans=true;break;}
    		i++;
    	}
    	if(ans) cout << "OK\n";
    	else cout << "NG\n";
    }
    return 0;
    //fflush(stdout);
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;
ll n;

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll k;
        cin>>n>>k;
        if(k == 1) cout<<0;
        else cout<<n-k;
    }
    end_routine();
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N, M;
      cin >> N >> M;
      N = min(M,N);
      vector<int> X (M);
      for(int i = 0;i < M;i++){
      	cin >> X[i];
      }
      SORT(X);
      vector<int> dis (M-1);
      int ans = 0;
      for(int i = 0;i < M-1;i++){
      	dis[i] = X[i+1]-X[i];
      	ans += dis[i];
      }
      SORT(dis);
      REV(dis);
      for(int i = 0;i < N-1;i++){
      	ans -= dis[i];
      }
      cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int n, h[100000+9], dp[100000+9];

int solve(int cur=0){
    if(cur == n-1) return 0;

    int &ret=dp[cur];
    if(ret != -1) return ret;

    ret =solve(cur+1)+abs(h[cur]-h[cur+1]);
    if(cur != n-2) ret = min(ret, solve(cur+2) + abs( h[cur]-h[cur+2] ));

    return ret;
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) dp[i]=-1;
    for(int i=0;i<n;i++) scanf("%d",&h[i]);
    printf("%d\n", solve());
    return 0;
}


Measured memory_bytes: 4096
import math
A, B = input().split()
A = int(A)

B_i = int(B[:-3])
B_f = int(B[-2:])


f = str(A*B_f)
if (len(f) >= 3):
    f_i = int(f[:-2])
else:
    f_i = 0

print(A*B_i + f_i)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 110000, mod = 1e9 + 7;

int n, x[N], ans;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

inline ll quickpow(ll base, ll pw) {
    ll ret = 1;
    while (pw) {
        if (pw & 1) ret = ret * base % mod;
        base = base * base % mod, pw >>= 1;
    }
    return ret;
}

int main() {
    read(n);
    ll fac = 1, sum = 0;
    for (R int i = 1; i <= n; ++i) read(x[i]);
    for (R int i = 1; i < n; ++i) fac = fac * i % mod;
    for (R int i = 1; i < n; ++i) {
        sum = (sum + fac * quickpow(i, mod - 2)) % mod;
        ans = (ans + (x[i + 1] - x[i]) * sum) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n; cin>>n;
    string s; cin>>s;
    int w[n+1],b[n+1];
    if(s[0]=='.'){
        w[0]=1;
        b[0]=0;
    }else{
        w[0]=0;
        b[0]=1;
    }
    for(int i=1;i<n;i++){
        w[i]=w[i-1];
        b[i]=b[i-1];
        if(s[i]=='.')w[i]++;
        else b[i]++;
    }
    int ans=min(w[n-1],b[n-1]);
    for(int i=1;i<n;i++){
        int t=b[i-1]+w[n-1]-w[i-1];
        ans=min(ans,t);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2180
#include<stdio.h>
#include<stdlib.h>

#define POS(i,j) ((i)*k+(j))

void run(void){
  int n;
  scanf("%d",&n);
  int k=1;
  while((k+1)*k/2<=n) k++;
  if(n!=k*(k-1)/2){
    printf("No\n");
    return;
  }
  printf("Yes\n%d\n",k);
  int *ans=(int *)calloc(k*k,sizeof(int));
  int p=1;
  int i,j;
  for(i=0;i<k;i++){
    for(j=i+1;j<k;j++){
      ans[POS(i,j)]=p;
      ans[POS(j,i)]=p;
      p++;
    }
  }
  for(i=0;i<k;i++){
    printf("%d",k-1);
    for(j=0;j<k;j++){
      if(i==j) continue;
      printf(" %d",ans[POS(i,j)]);
    }
    putchar('\n');
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

int A[100005];

map<int,int>mp;

typedef long long ll;

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	scanf(" %d",&A[i]);
	mp[A[i]]++;
	}

	sort(A,A+N);

	int h=0;
	int w=0;

	int flag=0;

	ll ans=0ll;

	for(i=N-1;i>=0;i--){
		if(mp[A[i]]>=2 && flag==0){
		h=A[i];
		mp[A[i]]-=2;
		flag++;
		}
		else if(mp[A[i]]>=2&&flag==1){
		w=A[i];
		break;
		}
	}

	ans=(ll)h*(ll)w;

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

	return 0;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

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



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

	while (1) {
		ll n, m; scanf("%lld %lld", &n, &m);
		if (n == 0 && m == 0) break;
		vector<ll> h(n); for (ll i = 0; i < n; i++) scanf("%lld", &h[i]);
		vector<ll> w(m); for (ll i = 0; i < m; i++) scanf("%lld", &w[i]);
		vector<ll> sum_h(n + 1), sum_w(m + 1);
		for (ll i = 0; i < n; i++) sum_h[i + 1] = sum_h[i] + h[i];
		for (ll i = 0; i < m; i++) sum_w[i + 1] = sum_w[i] + w[i];
		vector<ll> vh, vw;
		for (ll len = 1; len <= n; len++) {
			for (ll i = 0; i <= n - len; i++) {
				vh.push_back(sum_h[i + len] - sum_h[i]);
			}
		}

		for (ll len = 1; len <= m; len++) {
			for (ll i = 0; i <= m - len; i++) {
				vw.push_back(sum_w[i + len] - sum_w[i]);
			}
		}

		sort(vh.begin(), vh.end());
		sort(vw.begin(), vw.end());

		ll res = 0;
		for (ll i = 0; i < vh.size(); i++) {
			res += upper_bound(vw.begin(), vw.end(), vh[i]) - lower_bound(vw.begin(), vw.end(), vh[i]);

		}
		printf("%lld\n", res);
	}
	return 0;
}



Measured memory_bytes: 36972
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=100005;
LL A[N],B[N],K;
int P[N],d[N],t[N],i,j,k,n,m,x;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

LL read(){ int k=1; LL z=0; do c=getc(); while ((c<'0'||c>'9')&&c!='-'); if (c=='-') k=-1,c=getc(); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return k*z; }

void power(int *P,LL K)
{
	for (i=1;i<=n;++i) d[i]=i;
	for (;K;K>>=1)
	{
		if (K&1)
		{
			for (i=1;i<n;++i) t[i]=P[d[i]];
			for (i=1;i<n;++i) d[i]=t[i];
		}
		for (i=1;i<n;++i) t[i]=P[P[i]];
		for (i=1;i<n;++i) P[i]=t[i];
	}
}

int main()
{
	n=read();
	for (i=1;i<=n;++i) B[i]=read(),A[i-1]=B[i]-B[i-1],P[i]=i;
	m=read(),K=read();
	for (i=1;i<=m;++i) x=read(),swap(P[x-1],P[x]);
	power(P,K);
	for (i=1;i<=n;++i) B[i]=B[i-1]+A[d[i-1]],printf("%lld.0\n",B[i]);
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

int main() {
	int n,k;
	cin >> n >> k;
	p_int ss[n];
	bool use[100005];
	for (int i = 0;i < 100005;i++) {
		use[i] = false;
	}
	for (int i = 0;i < n;i++) {
		cin >> ss[i].second >> ss[i].first;
	}
	sort(ss,ss+n);
	reverse(ss,ss+n);
	vector<int> y0;
	vector<int> y1;
	for (int i = 0;i < n;i++) {
		if (!use[ss[i].second]) y1.push_back(ss[i].first);
		else y0.push_back(ss[i].first);
		use[ss[i].second] = true;
	}
	ll ans = 0;
	ll Y = max(0,k-int(y0.size()));
	ll X = 0;
	for (int i = 0;i < Y;i++) X += y1[i];
	for (int i = 0;i < k - Y;i++) X += y0[i];
	while (1) {
		ans = max(ans, X + Y*Y);
		if (Y >= k || Y >= y1.size()) break;
		X+=y1[Y];
		X-=y0[k-Y-1];
		Y++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1796
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    string s;
    cin>>s;
    int ans=0,temp=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        temp++;
        else
        {
            ans=max(ans,temp);
            temp=0;
        }
    }
    if(temp)
    ans=max(ans,temp);
    cout<<ans<<endl;
}


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

int main(){
    while(1){
        int n,x;
        cin>>n>>x;
        if((n==0)&&(x==0))break;
        int l=0;
        for(int i=1;i<=n;i++){
            for(int j=(i+1);(i<j)&&(j<=n);j++){
                for(int k=(j+1);(j<k)&&(k<=n);k++){
                    if((i+j+k)==x){
                        l+=1;
                    }
                }
            }
        }
        cout<<l<<endl;
    }
}


Measured memory_bytes: 3092